inline void
-g_sheet_column_set_width (GSheetColumn *column, gint col, gint size,
- gpointer data)
+g_sheet_column_set_width (GSheetColumn *column, gint col, gint size)
{
g_return_if_fail (G_IS_SHEET_COLUMN (column));
if ((G_SHEET_COLUMN_GET_IFACE (column)->set_width) )
- (G_SHEET_COLUMN_GET_IFACE (column)->set_width) (column, col, size, data);
+ (G_SHEET_COLUMN_GET_IFACE (column)->set_width) (column, col, size);
}
inline gint
-g_sheet_column_get_width (const GSheetColumn *column, gint col, gpointer data)
+g_sheet_column_get_width (const GSheetColumn *column, gint col)
{
g_return_val_if_fail (G_IS_SHEET_COLUMN (column), -1);
g_assert (G_SHEET_COLUMN_GET_IFACE (column)->get_width);
- return (G_SHEET_COLUMN_GET_IFACE (column)->get_width) (column, col, data);
+ return (G_SHEET_COLUMN_GET_IFACE (column)->get_width) (column, col);
}
inline gboolean
g_sheet_column_get_visibility(const GSheetColumn *column,
- gint col, gpointer data)
+ gint col)
{
g_return_val_if_fail (G_IS_SHEET_COLUMN (column), FALSE);
g_assert (G_SHEET_COLUMN_GET_IFACE (column)->get_visibility);
return (G_SHEET_COLUMN_GET_IFACE (column)->get_visibility) (column,
- col, data);
+ col);
}
inline gboolean
g_sheet_column_get_sensitivity(const GSheetColumn *column,
- gint col, gpointer data)
+ gint col)
{
g_return_val_if_fail (G_IS_SHEET_COLUMN (column), FALSE);
g_assert (G_SHEET_COLUMN_GET_IFACE (column)->get_sensitivity);
return (G_SHEET_COLUMN_GET_IFACE (column)->get_sensitivity) (column,
- col, data);
+ col);
}
inline GtkSheetButton *
g_sheet_column_get_button(const GSheetColumn *column,
- gint col, gpointer data)
+ gint col)
{
GtkSheetButton *button = gtk_sheet_button_new();
g_return_val_if_fail (G_IS_SHEET_COLUMN (column), FALSE);
if ( iface->get_button_label)
- button->label = iface->get_button_label(column, col, data);
+ button->label = iface->get_button_label(column, col);
return button;
}
inline GtkJustification
g_sheet_column_get_justification(const GSheetColumn *column,
- gint col, gpointer data)
+ gint col)
{
g_return_val_if_fail (G_IS_SHEET_COLUMN (column), FALSE);
g_assert (G_SHEET_COLUMN_GET_IFACE (column)->get_justification);
- return (G_SHEET_COLUMN_GET_IFACE (column)->get_justification) (column, col, data);
+ return (G_SHEET_COLUMN_GET_IFACE (column)->get_justification) (column, col);
}
inline gint
g_sheet_column_get_left_text_column (const GSheetColumn *column,
- gint col, gpointer data)
+ gint col)
{
g_return_val_if_fail (G_IS_SHEET_COLUMN (column), -1);
if ( ! G_SHEET_COLUMN_GET_IFACE (column)->get_left_text_column)
return col;
- return (G_SHEET_COLUMN_GET_IFACE (column)->get_left_text_column) (column, col, data);
+ return (G_SHEET_COLUMN_GET_IFACE (column)->get_left_text_column) (column, col);
}
inline gint
g_sheet_column_get_right_text_column (const GSheetColumn *column,
- gint col, gpointer data)
+ gint col)
{
g_return_val_if_fail (G_IS_SHEET_COLUMN (column), -1);
if ( ! G_SHEET_COLUMN_GET_IFACE (column)->get_right_text_column)
return col;
- return (G_SHEET_COLUMN_GET_IFACE (column)->get_right_text_column) (column, col, data);
+ return (G_SHEET_COLUMN_GET_IFACE (column)->get_right_text_column) (column, col);
}
inline void
g_sheet_column_set_left_text_column (const GSheetColumn *column,
- gint col, gint i, gpointer data)
+ gint col, gint i)
{
g_return_if_fail (G_IS_SHEET_COLUMN (column));
if ( G_SHEET_COLUMN_GET_IFACE (column)->set_left_text_column)
- (G_SHEET_COLUMN_GET_IFACE (column)->set_left_text_column) (column, col, i, data);
+ (G_SHEET_COLUMN_GET_IFACE (column)->set_left_text_column) (column, col, i);
}
inline void
g_sheet_column_set_right_text_column (const GSheetColumn *column,
- gint col, gint i, gpointer data)
+ gint col, gint i)
{
g_return_if_fail (G_IS_SHEET_COLUMN (column));
if ( G_SHEET_COLUMN_GET_IFACE (column)->set_right_text_column)
- (G_SHEET_COLUMN_GET_IFACE (column)->set_right_text_column) (column, col, i, data);
+ (G_SHEET_COLUMN_GET_IFACE (column)->set_right_text_column) (column, col, i);
}
inline gint
-g_sheet_column_get_column_count(const GSheetColumn *geo, gpointer data)
+g_sheet_column_get_column_count(const GSheetColumn *geo)
{
g_return_val_if_fail (G_IS_SHEET_COLUMN (geo), -1);
g_assert ( G_SHEET_COLUMN_GET_IFACE (geo)->get_column_count);
- return (G_SHEET_COLUMN_GET_IFACE (geo)->get_column_count) (geo, data);
+ return (G_SHEET_COLUMN_GET_IFACE (geo)->get_column_count) (geo);
}
inline gint
-g_sheet_column_start_pixel(const GSheetColumn *geo, gint col, gpointer data)
+g_sheet_column_start_pixel(const GSheetColumn *geo, gint col)
{
gint i;
gint start_pixel = 0;
g_return_val_if_fail (G_IS_SHEET_COLUMN (geo), -1);
g_return_val_if_fail (col <
- g_sheet_column_get_column_count(geo, data),-1);
+ g_sheet_column_get_column_count(geo),-1);
for ( i = 0 ; i < col ; ++i )
{
- if ( g_sheet_column_get_visibility(geo, i, data))
- start_pixel += g_sheet_column_get_width(geo, i, data);
+ if ( g_sheet_column_get_visibility(geo, i))
+ start_pixel += g_sheet_column_get_width(geo, i);
}
return start_pixel;
gint col, gint n_columns);
/* Virtual Table */
- gint (* get_width) (const GSheetColumn *gcolumn, gint col, gpointer data);
- void (* set_width) (GSheetColumn *gcolumn, gint col, gint width, gpointer data);
+ gint (* get_width) (const GSheetColumn *gcolumn, gint col);
+ void (* set_width) (GSheetColumn *gcolumn, gint col, gint width);
- gboolean (* get_visibility) (const GSheetColumn *gcolumn, gint col, gpointer data);
- gboolean (* get_sensitivity) (const GSheetColumn *gcolumn, gint col, gpointer data);
- const GtkSheetButton * (* get_button) (const GSheetColumn *gcolumn, gint col, gpointer data);
- GtkJustification (* get_justification) (const GSheetColumn *gcolumn, gint col, gpointer data);
+ gboolean (* get_visibility) (const GSheetColumn *gcolumn, gint col);
+ gboolean (* get_sensitivity) (const GSheetColumn *gcolumn, gint col);
+ const GtkSheetButton * (* get_button) (const GSheetColumn *gcolumn, gint col);
+ GtkJustification (* get_justification) (const GSheetColumn *gcolumn, gint col);
gint (*get_left_text_column) (const GSheetColumn *gcolumn,
- gint col, gpointer data);
+ gint col);
gint (*get_right_text_column) (const GSheetColumn *gcolumn,
- gint col, gpointer data);
+ gint col);
void (* set_left_text_column) (const GSheetColumn *gcolumn,
- gint col, gint i, gpointer data);
+ gint col, gint i);
void (* set_right_text_column) (const GSheetColumn *gcolumn,
- gint col, gint i, gpointer data);
+ gint col, gint i);
- gint (* get_column_count) (const GSheetColumn *geo, gpointer data);
+ gint (* get_column_count) (const GSheetColumn *geo);
- GtkStateType (*get_button_state)(const GSheetColumn *geo, gint col, gpointer data);
- gchar * (*get_button_label)(const GSheetColumn *geo, gint col, gpointer data);
+ GtkStateType (*get_button_state)(const GSheetColumn *geo, gint col);
+ gchar * (*get_button_label)(const GSheetColumn *geo, gint col);
gboolean (*get_button_visibility)(const GSheetColumn *geo,
- gint col, gpointer data);
+ gint col);
const GtkSheetChild * (*get_button_child)(const GSheetColumn *geo,
- gint col, gpointer data);
+ gint col);
GtkJustification * (*get_button_justification)(const GSheetColumn *geo,
- gint col, gpointer data);
+ gint col);
};
inline gint g_sheet_column_get_width (const GSheetColumn *gcolumn,
- gint col, gpointer data);
+ gint col);
inline void g_sheet_column_set_width (GSheetColumn *gcolumn,
- gint col, gint size, gpointer data);
+ gint col, gint size);
inline gboolean g_sheet_column_get_visibility(const GSheetColumn *gcolumn,
- gint col, gpointer data);
+ gint col);
inline gboolean g_sheet_column_get_sensitivity(const GSheetColumn *gcolumn,
- gint col, gpointer data);
+ gint col);
inline GtkSheetButton *g_sheet_column_get_button(const GSheetColumn *gcolumn,
- gint col, gpointer data);
+ gint col);
-inline GtkJustification g_sheet_column_get_justification(const GSheetColumn *gcolumn, gint col, gpointer data);
+inline GtkJustification g_sheet_column_get_justification(const GSheetColumn *gcolumn, gint col);
inline gint g_sheet_column_get_left_text_column (const GSheetColumn *gcolumn,
- gint col, gpointer data);
+ gint col);
inline gint g_sheet_column_get_right_text_column (const GSheetColumn *gcolumn,
- gint col, gpointer data);
+ gint col);
inline void g_sheet_column_set_left_text_column (const GSheetColumn *gcolumn,
- gint col, gint i, gpointer data);
+ gint col, gint i);
inline void g_sheet_column_set_right_text_column (const GSheetColumn *gcolumn,
- gint col, gint i, gpointer data);
+ gint col, gint i);
-inline gint g_sheet_column_get_column_count(const GSheetColumn *geo, gpointer data);
+inline gint g_sheet_column_get_column_count(const GSheetColumn *geo);
-inline gint g_sheet_column_start_pixel(const GSheetColumn *geo, gint col, gpointer data);
+inline gint g_sheet_column_start_pixel(const GSheetColumn *geo, gint col);
inline void g_sheet_column_columns_changed(GSheetColumn *geo,
gint first, gint n_columns);
}
static gint
-g_sheet_hetero_column_get_width(const GSheetColumn *geom, gint i, gpointer data)
+g_sheet_hetero_column_get_width(const GSheetColumn *geom, gint i)
{
GSheetHeteroColumn *hg = G_SHEET_HETERO_COLUMN(geom);
}
static gint
-g_sheet_hetero_column_get_sensitivity(const GSheetColumn *geom, gint u, gpointer data)
+g_sheet_hetero_column_get_sensitivity(const GSheetColumn *geom, gint u)
{
return TRUE;
}
static gint
-g_sheet_hetero_column_get_visibility(const GSheetColumn *geom, gint u, gpointer data)
+g_sheet_hetero_column_get_visibility(const GSheetColumn *geom, gint u)
{
return TRUE;
}
static gchar *
-g_sheet_hetero_column_get_button_label(const GSheetColumn *geom, gint u, gpointer data)
+g_sheet_hetero_column_get_button_label(const GSheetColumn *geom, gint u)
{
GSheetHeteroColumn *hg = G_SHEET_HETERO_COLUMN(geom);
static GtkJustification
-g_sheet_hetero_column_get_justification(const GSheetColumn *geom, gint u, gpointer data)
+g_sheet_hetero_column_get_justification(const GSheetColumn *geom, gint u)
{
return GTK_JUSTIFY_FILL;
}
static gint
-g_sheet_hetero_column_get_column_count(const GSheetColumn *geom, gpointer data)
+g_sheet_hetero_column_get_column_count(const GSheetColumn *geom)
{
GSheetHeteroColumn *hg = G_SHEET_HETERO_COLUMN(geom);
}
static void
-hetero_column_set_width(GSheetColumn *geo,
- gint i, gint size, gpointer data)
+hetero_column_set_width(GSheetColumn *geo, gint i, gint size)
{
GSheetHeteroColumn *hg = G_SHEET_HETERO_COLUMN(geo);
inline void
-g_sheet_hetero_column_set_width(GSheetHeteroColumn *geo,
- gint i, gint size)
+g_sheet_hetero_column_set_width(GSheetHeteroColumn *geo, gint i, gint size)
{
GSheetColumn *iface = G_SHEET_COLUMN(geo);
- hetero_column_set_width(iface, i, size, 0);
+ hetero_column_set_width(iface, i, size);
}
}
static gint
-g_sheet_uniform_column_get_width(const GSheetColumn *geom, gint u, gpointer data)
+g_sheet_uniform_column_get_width(const GSheetColumn *geom, gint u)
{
GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
}
static gint
-g_sheet_uniform_column_get_sensitivity(const GSheetColumn *geom, gint u, gpointer data)
+g_sheet_uniform_column_get_sensitivity(const GSheetColumn *geom, gint u)
{
GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
static gint
-g_sheet_uniform_column_get_visibility(const GSheetColumn *geom, gint u, gpointer data)
+g_sheet_uniform_column_get_visibility(const GSheetColumn *geom, gint u)
{
GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
static gchar *
-g_sheet_uniform_column_get_button_label(const GSheetColumn *geom, gint u, gpointer data)
+g_sheet_uniform_column_get_button_label(const GSheetColumn *geom, gint u)
{
gchar *label = g_strdup_printf("%d", u);
static GtkJustification
-g_sheet_uniform_column_get_justification(const GSheetColumn *geom, gint u, gpointer data)
+g_sheet_uniform_column_get_justification(const GSheetColumn *geom, gint u)
{
return GTK_JUSTIFY_FILL;
}
static gint
-g_sheet_uniform_column_get_column_count(const GSheetColumn *geom, gpointer data)
+g_sheet_uniform_column_get_column_count(const GSheetColumn *geom)
{
GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN(geom);
GSheetColumn *col_geo = sheet->column_geometry;
if ( col < 0 ) return NULL ;
- return g_sheet_column_get_button(col_geo, col, 0);
+ return g_sheet_column_get_button(col_geo, col);
}
{
GSheetColumn *geo = sheet->column_geometry;
- /* FIXME: Get rid of this nasty cast.
- In fact, get rid of this entire variable */
- gint x = g_sheet_column_start_pixel(geo, col, (GtkSheet *) sheet);
+ gint x = g_sheet_column_start_pixel(geo, col);
if ( sheet->row_titles_visible )
x += sheet->row_title_area.width;
{
GSheetColumn *col_geo = sheet->column_geometry;
- /* FIXME: Get rid of this nasty cast.
- In fact, get rid of this entire variable */
- return g_sheet_column_get_width(col_geo, col, (GtkSheet *)sheet);
+ return g_sheet_column_get_width(col_geo, col);
}
xxx_set_column_width(GtkSheet *sheet, gint col, gint width)
{
if ( sheet->column_geometry )
- g_sheet_column_set_width(sheet->column_geometry, col, width, sheet);
+ g_sheet_column_set_width(sheet->column_geometry, col, width);
}
static inline void
{
GSheetColumn *col_geo = sheet->column_geometry;
- g_sheet_column_set_left_text_column(col_geo, col, i, sheet);
+ g_sheet_column_set_left_text_column(col_geo, col, i);
}
static inline gint
{
GSheetColumn *col_geo = sheet->column_geometry;
- return g_sheet_column_get_left_text_column(col_geo, col, 0);
+ return g_sheet_column_get_left_text_column(col_geo, col);
}
static inline void
{
GSheetColumn *col_geo = sheet->column_geometry;
- g_sheet_column_set_right_text_column(col_geo, col, i, 0);
+ g_sheet_column_set_right_text_column(col_geo, col, i);
}
static inline gint
{
GSheetColumn *col_geo = sheet->column_geometry;
- return g_sheet_column_get_right_text_column(col_geo, col, 0);
+ return g_sheet_column_get_right_text_column(col_geo, col);
}
static inline GtkJustification
{
GSheetColumn *col_geo = sheet->column_geometry;
- return g_sheet_column_get_justification(col_geo, col, 0);
+ return g_sheet_column_get_justification(col_geo, col);
}
static inline gint
{
GSheetColumn *col_geo = sheet->column_geometry;
- return g_sheet_column_get_visibility(col_geo, col, 0);
+ return g_sheet_column_get_visibility(col_geo, col);
}
{
GSheetColumn *col_geo = sheet->column_geometry;
- return g_sheet_column_get_sensitivity(col_geo, col, 0);
+ return g_sheet_column_get_sensitivity(col_geo, col);
}
{
GSheetColumn *col_geo = sheet->column_geometry;
- return g_sheet_column_get_column_count(col_geo, 0);
+ return g_sheet_column_get_column_count(col_geo);
}
/* returns the column index from a x pixel location in the
POSSIBLE_YDRAG(const GtkSheet *sheet, gint y, gint *drag_row)
{
gint row, ydrag;
-
row=ROW_FROM_YPIXEL(sheet, y);
*drag_row=row;
gint *drag_row, gint *drag_column)
{
gint xdrag, ydrag;
-
+
/* Can't drag if nothing is selected */
if ( sheet->range.row0 < 0 || sheet->range.rowi < 0 ||
sheet->range.col0 < 0 || sheet->range.coli < 0 )
g_return_if_fail (sheet != NULL);
- if(range==NULL) range=&sheet->range;
+ if(range == NULL) range = &sheet->range;
memcpy(&sheet->range, range, sizeof(*range));
state = sheet->state;
-#if 0
- if(state==GTK_SHEET_COLUMN_SELECTED || state==GTK_SHEET_RANGE_SELECTED){
- for(i=sheet->range.col0; i< range->col0; i++)
- column_button_release(sheet, i);
- for(i=range->coli+1; i<= sheet->range.coli; i++)
- column_button_release(sheet, i);
- for(i=range->col0; i<=range->coli; i++){
- column_button_set(sheet, i);
- }
- }
-
- if(state==GTK_SHEET_ROW_SELECTED || state==GTK_SHEET_RANGE_SELECTED){
- for(i=sheet->range.row0; i< range->row0; i++)
- row_button_release(sheet, i);
- for(i=range->rowi+1; i<= sheet->range.rowi; i++)
- row_button_release(sheet, i);
- for(i=range->row0; i<=range->rowi; i++){
- row_button_set(sheet, i);
- }
- }
-#endif
-
if(range->coli != sheet->range.coli || range->col0 != sheet->range.col0 ||
range->rowi != sheet->range.rowi || range->row0 != sheet->range.row0)
{
-
- gtk_sheet_new_selection(sheet, range);
-
- sheet->range.col0=range->col0;
- sheet->range.coli=range->coli;
- sheet->range.row0=range->row0;
- sheet->range.rowi=range->rowi;
-
+ gtk_sheet_new_selection(sheet, &sheet->range);
}
else
{
gtk_sheet_range_draw_selection(sheet, sheet->range);
}
- gtk_signal_emit(GTK_OBJECT(sheet), sheet_signals[SELECT_RANGE], range);
+ gtk_signal_emit(GTK_OBJECT(sheet), sheet_signals[SELECT_RANGE], &sheet->range);
}
void
sheet=GTK_SHEET(widget);
/* release on resize windows */
- if (GTK_SHEET_IN_XDRAG (sheet)){
- GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IN_XDRAG);
- GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IN_SELECTION);
- gtk_widget_get_pointer (widget, &x, NULL);
- gdk_pointer_ungrab (event->time);
- draw_xor_vline (sheet);
+ if (GTK_SHEET_IN_XDRAG (sheet))
+ {
+ GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IN_XDRAG);
+ GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IN_SELECTION);
+ gtk_widget_get_pointer (widget, &x, NULL);
+ gdk_pointer_ungrab (event->time);
+ draw_xor_vline (sheet);
- gtk_sheet_set_column_width (sheet, sheet->drag_cell.col, new_column_width (sheet, sheet->drag_cell.col, &x));
- sheet->old_hadjustment = -1.;
- gtk_signal_emit_by_name (GTK_OBJECT (sheet->hadjustment), "value_changed");
- return TRUE;
- }
+ gtk_sheet_set_column_width (sheet, sheet->drag_cell.col,
+ new_column_width (sheet, sheet->drag_cell.col, &x));
+ sheet->old_hadjustment = -1.;
+ gtk_signal_emit_by_name (GTK_OBJECT (sheet->hadjustment), "value_changed");
+ return TRUE;
+ }
if (GTK_SHEET_IN_YDRAG (sheet)){
GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IN_YDRAG);
sheet_entry = GTK_ENTRY(gtk_sheet_get_entry(sheet));
- gtk_sheet_get_attributes(sheet, sheet->active_cell.row, sheet->active_cell.col, &attributes);
-
- if(GTK_WIDGET_REALIZED(sheet->sheet_entry))
- {
-
- if(!GTK_WIDGET(sheet_entry)->style)
- gtk_widget_ensure_style(GTK_WIDGET(sheet_entry));
-
- previous_style = GTK_WIDGET(sheet_entry)->style;
-
- style = gtk_style_copy(previous_style);
- style->bg[GTK_STATE_NORMAL] = attributes.background;
- style->fg[GTK_STATE_NORMAL] = attributes.foreground;
- style->text[GTK_STATE_NORMAL] = attributes.foreground;
- style->bg[GTK_STATE_ACTIVE] = attributes.background;
- style->fg[GTK_STATE_ACTIVE] = attributes.foreground;
- style->text[GTK_STATE_ACTIVE] = attributes.foreground;
-
- pango_font_description_free(style->font_desc);
- style->font_desc = pango_font_description_copy(attributes.font_desc);
-
- GTK_WIDGET(sheet_entry)->style = style;
- gtk_widget_size_request(sheet->sheet_entry, NULL);
- GTK_WIDGET(sheet_entry)->style = previous_style;
+ if ( ! gtk_sheet_get_attributes(sheet, sheet->active_cell.row,
+ sheet->active_cell.col,
+ &attributes) )
+ return ;
- if(style != previous_style){
- if(!GTK_IS_ITEM_ENTRY(sheet->sheet_entry)){
- style->bg[GTK_STATE_NORMAL] = previous_style->bg[GTK_STATE_NORMAL];
- style->fg[GTK_STATE_NORMAL] = previous_style->fg[GTK_STATE_NORMAL];
- style->bg[GTK_STATE_ACTIVE] = previous_style->bg[GTK_STATE_ACTIVE];
- style->fg[GTK_STATE_ACTIVE] = previous_style->fg[GTK_STATE_ACTIVE];
- }
- gtk_widget_set_style(GTK_WIDGET(sheet_entry), style);
- }
- }
+ if ( GTK_WIDGET_REALIZED(sheet->sheet_entry) )
+ {
+ if(!GTK_WIDGET(sheet_entry)->style)
+ gtk_widget_ensure_style(GTK_WIDGET(sheet_entry));
+
+ previous_style = GTK_WIDGET(sheet_entry)->style;
+
+ style = gtk_style_copy(previous_style);
+ style->bg[GTK_STATE_NORMAL] = attributes.background;
+ style->fg[GTK_STATE_NORMAL] = attributes.foreground;
+ style->text[GTK_STATE_NORMAL] = attributes.foreground;
+ style->bg[GTK_STATE_ACTIVE] = attributes.background;
+ style->fg[GTK_STATE_ACTIVE] = attributes.foreground;
+ style->text[GTK_STATE_ACTIVE] = attributes.foreground;
+
+ pango_font_description_free(style->font_desc);
+ g_assert(attributes.font_desc);
+ style->font_desc = pango_font_description_copy(attributes.font_desc);
+
+ GTK_WIDGET(sheet_entry)->style = style;
+ gtk_widget_size_request(sheet->sheet_entry, NULL);
+ GTK_WIDGET(sheet_entry)->style = previous_style;
+
+ if(style != previous_style){
+ if(!GTK_IS_ITEM_ENTRY(sheet->sheet_entry)){
+ style->bg[GTK_STATE_NORMAL] = previous_style->bg[GTK_STATE_NORMAL];
+ style->fg[GTK_STATE_NORMAL] = previous_style->fg[GTK_STATE_NORMAL];
+ style->bg[GTK_STATE_ACTIVE] = previous_style->bg[GTK_STATE_ACTIVE];
+ style->fg[GTK_STATE_ACTIVE] = previous_style->fg[GTK_STATE_ACTIVE];
+ }
+ gtk_widget_set_style(GTK_WIDGET(sheet_entry), style);
+ }
+ }
if(GTK_IS_ITEM_ENTRY(sheet_entry))
- max_size = GTK_ITEM_ENTRY(sheet_entry)->text_max_size;
+ max_size = GTK_ITEM_ENTRY(sheet_entry)->text_max_size;
else
- max_size = 0;
+ max_size = 0;
text_size = 0;
text = gtk_entry_get_text(GTK_ENTRY(sheet_entry));
- if(text && strlen(text) > 0){
- text_size = STRING_WIDTH(GTK_WIDGET(sheet), attributes.font_desc, text);
- }
+ if(text && strlen(text) > 0)
+ text_size = STRING_WIDTH(GTK_WIDGET(sheet), attributes.font_desc, text);
column_width=xxx_column_width(sheet, sheet->active_cell.col);
shentry_allocation.width = column_width;
shentry_allocation.height = yyy_row_height(sheet, sheet->active_cell.row);
- if(GTK_IS_ITEM_ENTRY(sheet->sheet_entry)){
-
- shentry_allocation.height -= 2*CELLOFFSET;
- shentry_allocation.y += CELLOFFSET;
- if(gtk_sheet_clip_text(sheet))
- shentry_allocation.width = column_width - 2*CELLOFFSET;
- else
- shentry_allocation.width = size;
-
- switch(GTK_ITEM_ENTRY(sheet_entry)->justification){
+ if(GTK_IS_ITEM_ENTRY(sheet->sheet_entry))
+ {
+ shentry_allocation.height -= 2*CELLOFFSET;
+ shentry_allocation.y += CELLOFFSET;
+ if(gtk_sheet_clip_text(sheet))
+ shentry_allocation.width = column_width - 2*CELLOFFSET;
+ else
+ shentry_allocation.width = size;
+
+ switch(GTK_ITEM_ENTRY(sheet_entry)->justification){
case GTK_JUSTIFY_CENTER:
shentry_allocation.x += (column_width)/2 - size/2;
break;
case GTK_JUSTIFY_FILL:
shentry_allocation.x += CELLOFFSET;
break;
- }
-
- }
+ }
+ }
if(!GTK_IS_ITEM_ENTRY(sheet->sheet_entry))
{
row=sheet->active_cell.row;
col=sheet->active_cell.col;
- if(!GTK_IS_ITEM_ENTRY(sheet->sheet_entry) || gtk_sheet_clip_text(sheet)) return;
+ if( ! GTK_IS_ITEM_ENTRY(sheet->sheet_entry) || gtk_sheet_clip_text(sheet))
+ return;
justification = GTK_ITEM_ENTRY(sheet->sheet_entry)->justification;
xxx_set_column_width(sheet, column, width);
sheet->view.coli = COLUMN_FROM_XPIXEL(sheet, sheet->sheet_window_width);
size_allocate_column_title_buttons (sheet);
-
+
return width;
}
xxx_set_column_width(sheet, column, width);
- if(GTK_WIDGET_REALIZED(GTK_WIDGET(sheet)) && !GTK_SHEET_IS_FROZEN(sheet)){
- size_allocate_column_title_buttons (sheet);
- adjust_scrollbars (sheet);
- gtk_sheet_size_allocate_entry(sheet);
- gtk_sheet_range_draw (sheet, NULL);
- } else
-
+ if(GTK_WIDGET_REALIZED(GTK_WIDGET(sheet)) && !GTK_SHEET_IS_FROZEN(sheet))
+ {
+ size_allocate_column_title_buttons (sheet);
+ adjust_scrollbars (sheet);
+ gtk_sheet_size_allocate_entry(sheet);
+ gtk_sheet_range_draw (sheet, NULL);
+ }
+
gtk_signal_emit(GTK_OBJECT(sheet), sheet_signals[CHANGED], -1, column);
- gtk_signal_emit(GTK_OBJECT(sheet), sheet_signals[NEW_COL_WIDTH], column, width);
-
+ gtk_signal_emit(GTK_OBJECT(sheet), sheet_signals[NEW_COL_WIDTH],
+ column, width);
}
-* Crashes when resizing rows/columns when no cell is selected.
-
* Blank cell reference when deselecting cells. (Eg New command).
* Strip leading/trailing whitespace on data in cells.
* Case weights.
-* Resizing of string variables.
-
* Goto Variable.
* Widen columns in var sheet as necessary to accomodate non-english translations.
return FALSE;
}
-
extern PsppireDataStore *data_store ;
+/* Return the width that an 'M' character would occupy when typeset in WIDGET */
+static guint
+calc_m_width(GtkWidget *widget, const PangoFontDescription *font_desc)
+{
+ PangoRectangle rect;
+ PangoLayout *layout ;
+ PangoContext * context;
+
+ context = gtk_widget_create_pango_context (widget);
+ g_assert (context);
+ layout = pango_layout_new (context);
+ g_assert (layout);
+
+ pango_layout_set_text (layout, "M", 1);
+
+ pango_layout_set_font_description (layout, font_desc);
+
+ pango_layout_get_extents (layout, NULL, &rect);
+
+ g_object_unref(G_OBJECT(layout));
+ g_object_unref(G_OBJECT(context));
+
+ return PANGO_PIXELS(rect.width);
+}
+
+
+
+void
+font_change_callback(GObject *obj, gpointer data)
+{
+ GtkWidget *sheet = data;
+ PsppireDataStore *ds = PSPPIRE_DATA_STORE(obj);
+
+ ds->width_of_m = calc_m_width(sheet, ds->font_desc);
+}
+
GtkWidget*
psppire_data_sheet_create (gchar *widget_name, gchar *string1, gchar *string2,
gint int1, gint int2)
sheet = gtk_sheet_new(G_SHEET_ROW(data_store),
G_SHEET_COLUMN(data_store), "data sheet", 0);
+ data_store->width_of_m = calc_m_width(sheet, data_store->font_desc);
- g_signal_connect (GTK_OBJECT (sheet), "activate",
- GTK_SIGNAL_FUNC (update_data_ref_entry),
+ g_signal_connect (G_OBJECT (sheet), "activate",
+ G_CALLBACK (update_data_ref_entry),
0);
- g_signal_connect (GTK_OBJECT (sheet), "traverse",
- GTK_SIGNAL_FUNC (traverse_callback), 0);
+ g_signal_connect (G_OBJECT (sheet), "traverse",
+ G_CALLBACK (traverse_callback), 0);
- g_signal_connect (GTK_OBJECT (sheet), "double-click-column",
- GTK_SIGNAL_FUNC (click2column),
+ g_signal_connect (G_OBJECT (sheet), "double-click-column",
+ G_CALLBACK (click2column),
0);
+ g_signal_connect (G_OBJECT (data_store), "font-changed",
+ G_CALLBACK (font_change_callback), sheet);
+
gtk_sheet_set_active_cell(GTK_SHEET(sheet), -1, -1);
gtk_widget_show(sheet);
#include <gtksheet/gsheetmodel.h>
#include <gtksheet/gsheet-column-iface.h>
+#include <pango/pango-context.h>
+
#include "psppire-variable.h"
#include "psppire-data-store.h"
#include "helper.h"
static GObjectClass *parent_class = NULL;
+
+enum {FONT_CHANGED,
+ n_SIGNALS};
+
+static guint signal[n_SIGNALS];
+
+
inline GType
psppire_data_store_get_type (void)
{
return data_store_type;
}
+
static void
psppire_data_store_class_init (PsppireDataStoreClass *class)
{
object_class = (GObjectClass*) class;
object_class->finalize = psppire_data_store_finalize;
+
+ signal[FONT_CHANGED] =
+ g_signal_new ("font_changed",
+ G_TYPE_FROM_CLASS(class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
{
data_store->dict = 0;
data_store->case_file = 0;
+ data_store->width_of_m = 10;
}
const PangoFontDescription *
void
-psppire_data_store_set_font(PsppireDataStore *store, PangoFontDescription *fd)
+psppire_data_store_set_font(PsppireDataStore *store,
+ const PangoFontDescription *fd)
{
g_return_if_fail (store);
g_return_if_fail (PSPPIRE_IS_DATA_STORE (store));
store->font_desc = fd;
+#if 0
+ store->width_of_m = calc_m_width(fd);
+#endif
+ g_signal_emit(store, signal[FONT_CHANGED], 0);
+
+
g_sheet_model_range_changed (G_SHEET_MODEL(store),
-1, -1, -1, -1);
}
/* Column related funcs */
static gint
-geometry_get_column_count(const GSheetColumn *geom, gpointer data)
+geometry_get_column_count(const GSheetColumn *geom)
{
PsppireDataStore *ds = PSPPIRE_DATA_STORE(geom);
return MAX(MIN_COLUMNS, psppire_dict_get_var_cnt(ds->dict));
}
-/* Return the width that an 'M' character would occupy when typeset at
- row, col */
-static guint
-M_width(const GtkSheet *sheet, gint row, gint col)
-{
- GtkSheetCellAttr attributes;
- PangoRectangle rect;
- /* FIXME: make this a member of the data store */
- static PangoLayout *layout = 0;
-
- gtk_sheet_get_attributes(sheet, row, col, &attributes);
-
- if (! layout )
- layout = gtk_widget_create_pango_layout (GTK_WIDGET(sheet), "M");
-
- g_assert(layout);
-
- pango_layout_set_font_description (layout,
- attributes.font_desc);
-
- pango_layout_get_extents (layout, NULL, &rect);
-
-#if 0
- g_object_unref(G_OBJECT(layout));
-#endif
-
- return PANGO_PIXELS(rect.width);
-}
-
-
-/* Return the number of pixels corresponding to a column of
- WIDTH characters */
-static inline guint
-columnWidthToPixels(GtkSheet *sheet, gint column, guint width)
-{
- return (M_width(sheet, 0, column) * width);
-}
static gint
-geometry_get_width(const GSheetColumn *geom, gint unit, GtkSheet *sheet)
+geometry_get_width(const GSheetColumn *geom, gint unit)
{
const struct PsppireVariable *pv ;
PsppireDataStore *ds = PSPPIRE_DATA_STORE(geom);
if ( unit >= psppire_dict_get_var_cnt(ds->dict) )
- return 75;
+ return ds->width_of_m * 8 ;
- /* FIXME: We can optimise this by caching the widths until they're resized */
pv = psppire_dict_get_variable(ds->dict, unit);
- return columnWidthToPixels(sheet, unit, psppire_variable_get_columns(pv));
-}
-
-
+ if ( pv == NULL )
+ return ds->width_of_m * 8 ;
+ return ds->width_of_m * psppire_variable_get_columns(pv);
+}
static void
-geometry_set_width(GSheetColumn *geom, gint unit, gint width, GtkSheet *sheet)
+geometry_set_width(GSheetColumn *geom, gint unit, gint width)
{
PsppireDataStore *ds = PSPPIRE_DATA_STORE(geom);
struct PsppireVariable *pv = psppire_dict_get_variable(ds->dict, unit);
- psppire_variable_set_columns(pv, width / M_width(sheet, 1, unit));
+ psppire_variable_set_columns(pv, width / ds->width_of_m );
}
static GtkJustification
-geometry_get_justification(const GSheetColumn *geom, gint unit, gpointer data)
+geometry_get_justification(const GSheetColumn *geom, gint unit)
{
PsppireDataStore *ds = PSPPIRE_DATA_STORE(geom);
const struct PsppireVariable *pv ;
static const gchar null_var_name[]=N_("var");
static gchar *
-geometry_get_column_button_label(const GSheetColumn *geom, gint unit,
- gpointer data)
+geometry_get_column_button_label(const GSheetColumn *geom, gint unit)
{
gchar *text;
struct PsppireVariable *pv ;
static gboolean
-geometry_get_sensitivity(const GSheetColumn *geom, gint unit, gpointer data)
+geometry_get_sensitivity(const GSheetColumn *geom, gint unit)
{
PsppireDataStore *ds = PSPPIRE_DATA_STORE(geom);
iface->get_button_label = geometry_get_row_button_label;
}
-
-
-
-
/*< private >*/
PsppireDict *dict;
PsppireCaseFile *case_file;
- PangoFontDescription *font_desc;
+ const PangoFontDescription *font_desc;
+
+ /* The width of an upper case 'M' rendered in the current font */
+ gint width_of_m ;
+
gboolean show_labels;
/* Geometry */
inline GType psppire_data_store_get_type (void) G_GNUC_CONST;
PsppireDataStore *psppire_data_store_new (PsppireDict *dict);
-void psppire_data_store_set_dictionary(PsppireDataStore *data_store, PsppireDict *dict);
-void psppire_data_store_set_font(PsppireDataStore *store, PangoFontDescription *fd);
+void psppire_data_store_set_dictionary(PsppireDataStore *data_store,
+ PsppireDict *dict);
-void psppire_data_store_show_labels(PsppireDataStore *store, gboolean show_labels);
+void psppire_data_store_set_font(PsppireDataStore *store,
+ const PangoFontDescription *fd);
+void psppire_data_store_show_labels(PsppireDataStore *store,
+ gboolean show_labels);
void psppire_data_store_clear(PsppireDataStore *data_store);
-
-
-
struct file_handle;
void psppire_data_store_create_system_file(PsppireDataStore *store,