Commit 1ee3df51 authored by Benjamin Otte's avatar Benjamin Otte

cellrendertoggle: Draw background + frame for mark

Also compute padding and borders properly for the marks.
parent 46f46ed3
......@@ -335,12 +335,21 @@ gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
gint calc_width;
gint calc_height;
gint xpad, ypad;
GtkStyleContext *context;
GtkBorder border, padding;
priv = GTK_CELL_RENDERER_TOGGLE (cell)->priv;
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
calc_width = xpad * 2 + priv->indicator_size;
calc_height = ypad * 2 + priv->indicator_size;
context = gtk_cell_renderer_toggle_save_context (cell, widget);
gtk_style_context_get_padding (context, gtk_style_context_get_state (context), &padding);
gtk_style_context_get_border (context, gtk_style_context_get_state (context), &border);
calc_width = xpad * 2 + priv->indicator_size + padding.left + padding.right + border.left + border.right;
calc_height = ypad * 2 + priv->indicator_size + padding.top + padding.bottom + border.top + border.bottom;
gtk_style_context_restore (context);
if (width)
*width = calc_width;
......@@ -388,6 +397,7 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
gint x_offset, y_offset;
gint xpad, ypad;
GtkStateFlags state;
GtkBorder padding, border;
context = gtk_widget_get_style_context (widget);
gtk_cell_renderer_toggle_get_size (cell, widget, cell_area,
......@@ -421,19 +431,33 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
context = gtk_cell_renderer_toggle_save_context (cell, widget);
gtk_style_context_set_state (context, state);
if (priv->radio)
{
gtk_render_option (context, cr,
gtk_render_background (context, cr,
cell_area->x + x_offset + xpad,
cell_area->y + y_offset + ypad,
width, height);
gtk_render_frame (context, cr,
cell_area->x + x_offset + xpad,
cell_area->y + y_offset + ypad,
width, height);
gtk_style_context_get_padding (context, gtk_style_context_get_state (context), &padding);
gtk_style_context_get_border (context, gtk_style_context_get_state (context), &border);
if (priv->radio)
{
gtk_render_option (context, cr,
cell_area->x + x_offset + xpad + padding.left + border.left,
cell_area->y + y_offset + ypad + padding.top + border.top,
width - padding.left - padding.right - border.left - border.right,
height - padding.top - padding.bottom - border.top - border.bottom);
}
else
{
gtk_render_check (context, cr,
cell_area->x + x_offset + xpad,
cell_area->y + y_offset + ypad,
width, height);
cell_area->x + x_offset + xpad + padding.left + border.left,
cell_area->y + y_offset + ypad + padding.top + border.top,
width - padding.left - padding.right - border.left - border.right,
height - padding.top - padding.bottom - border.top - border.bottom);
}
gtk_style_context_restore (context);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment