forked from AuroraMiddleware/gtk
calendar: use CSS paddings instead of focus pad for day/week areas
focus-padding is going away.
This commit is contained in:
parent
83b4e67307
commit
1e66a7ccdb
@ -1845,7 +1845,49 @@ gtk_calendar_query_tooltip (GtkWidget *widget,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_component_paddings (GtkCalendar *calendar,
|
||||||
|
GtkBorder *padding,
|
||||||
|
GtkBorder *day_padding,
|
||||||
|
GtkBorder *day_name_padding,
|
||||||
|
GtkBorder *week_padding)
|
||||||
|
{
|
||||||
|
GtkStyleContext * context;
|
||||||
|
GtkStateFlags state;
|
||||||
|
GtkWidget *widget;
|
||||||
|
|
||||||
|
widget = GTK_WIDGET (calendar);
|
||||||
|
context = gtk_widget_get_style_context (widget);
|
||||||
|
state = gtk_widget_get_state_flags (widget);
|
||||||
|
|
||||||
|
if (padding)
|
||||||
|
gtk_style_context_get_padding (context, state, padding);
|
||||||
|
|
||||||
|
if (day_padding)
|
||||||
|
{
|
||||||
|
gtk_style_context_save (context);
|
||||||
|
gtk_style_context_add_class (context, "day-number");
|
||||||
|
gtk_style_context_get_padding (context, state, day_padding);
|
||||||
|
gtk_style_context_restore (context);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (day_name_padding)
|
||||||
|
{
|
||||||
|
gtk_style_context_save (context);
|
||||||
|
gtk_style_context_add_class (context, "day-name");
|
||||||
|
gtk_style_context_get_padding (context, state, day_name_padding);
|
||||||
|
gtk_style_context_restore (context);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (week_padding)
|
||||||
|
{
|
||||||
|
gtk_style_context_save (context);
|
||||||
|
gtk_style_context_add_class (context, "week-number");
|
||||||
|
gtk_style_context_get_padding (context, state, week_padding);
|
||||||
|
gtk_style_context_restore (context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************
|
/****************************************
|
||||||
* Size Request and Allocate *
|
* Size Request and Allocate *
|
||||||
****************************************/
|
****************************************/
|
||||||
@ -1856,9 +1898,7 @@ gtk_calendar_size_request (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GtkCalendar *calendar = GTK_CALENDAR (widget);
|
GtkCalendar *calendar = GTK_CALENDAR (widget);
|
||||||
GtkCalendarPrivate *priv = calendar->priv;
|
GtkCalendarPrivate *priv = calendar->priv;
|
||||||
GtkStyleContext *context;
|
GtkBorder padding, day_padding, day_name_padding, week_padding;
|
||||||
GtkStateFlags state;
|
|
||||||
GtkBorder padding;
|
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
PangoRectangle logical_rect;
|
PangoRectangle logical_rect;
|
||||||
|
|
||||||
@ -1868,15 +1908,15 @@ gtk_calendar_size_request (GtkWidget *widget,
|
|||||||
gint header_width, main_width;
|
gint header_width, main_width;
|
||||||
gint max_header_height = 0;
|
gint max_header_height = 0;
|
||||||
gint focus_width;
|
gint focus_width;
|
||||||
gint focus_padding;
|
|
||||||
gint max_detail_height;
|
gint max_detail_height;
|
||||||
gint inner_border = calendar_get_inner_border (calendar);
|
gint inner_border = calendar_get_inner_border (calendar);
|
||||||
gint calendar_ysep = calendar_get_ysep (calendar);
|
gint calendar_ysep = calendar_get_ysep (calendar);
|
||||||
gint calendar_xsep = calendar_get_xsep (calendar);
|
gint calendar_xsep = calendar_get_xsep (calendar);
|
||||||
|
|
||||||
|
gboolean show_week_numbers = (priv->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS);
|
||||||
|
|
||||||
gtk_widget_style_get (GTK_WIDGET (widget),
|
gtk_widget_style_get (GTK_WIDGET (widget),
|
||||||
"focus-line-width", &focus_width,
|
"focus-line-width", &focus_width,
|
||||||
"focus-padding", &focus_padding,
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
layout = gtk_widget_create_pango_layout (widget, NULL);
|
layout = gtk_widget_create_pango_layout (widget, NULL);
|
||||||
@ -1964,7 +2004,7 @@ gtk_calendar_size_request (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
priv->max_week_char_width = 0;
|
priv->max_week_char_width = 0;
|
||||||
if (priv->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS)
|
if (show_week_numbers)
|
||||||
for (i = 0; i < 9; i++)
|
for (i = 0; i < 9; i++)
|
||||||
{
|
{
|
||||||
gchar buffer[32];
|
gchar buffer[32];
|
||||||
@ -2043,18 +2083,20 @@ gtk_calendar_size_request (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_component_paddings (calendar, &padding, &day_padding, &day_name_padding, &week_padding);
|
||||||
|
|
||||||
|
priv->min_day_width += day_padding.left + day_padding.right;
|
||||||
|
if (show_week_numbers)
|
||||||
|
priv->max_week_char_width += week_padding.left + week_padding.right;
|
||||||
|
|
||||||
/* We add one to max_day_char_width to be able to make the marked day "bold" */
|
/* We add one to max_day_char_width to be able to make the marked day "bold" */
|
||||||
priv->max_day_char_width = priv->min_day_width / 2 + 1;
|
priv->max_day_char_width = priv->min_day_width / 2 + 1;
|
||||||
|
|
||||||
main_width = (7 * (priv->min_day_width + (focus_padding + focus_width) * 2) + (DAY_XSEP * 6) + CALENDAR_MARGIN * 2
|
main_width = (7 * (priv->min_day_width + (focus_width) * 2) + (DAY_XSEP * 6) + CALENDAR_MARGIN * 2
|
||||||
+ (priv->max_week_char_width
|
+ (show_week_numbers
|
||||||
? priv->max_week_char_width * 2 + (focus_padding + focus_width) * 2 + calendar_xsep * 2
|
? priv->max_week_char_width * 2 + (focus_width) * 2 + calendar_xsep * 2
|
||||||
: 0));
|
: 0));
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (widget);
|
|
||||||
state = gtk_widget_get_state_flags (widget);
|
|
||||||
gtk_style_context_get_padding (context, state, &padding);
|
|
||||||
|
|
||||||
requisition->width = MAX (header_width, main_width + inner_border * 2) + padding.left + padding.right;
|
requisition->width = MAX (header_width, main_width + inner_border * 2) + padding.left + padding.right;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2073,8 +2115,9 @@ gtk_calendar_size_request (GtkWidget *widget,
|
|||||||
if (priv->display_flags & GTK_CALENDAR_SHOW_DAY_NAMES)
|
if (priv->display_flags & GTK_CALENDAR_SHOW_DAY_NAMES)
|
||||||
{
|
{
|
||||||
priv->day_name_h = (priv->max_label_char_ascent
|
priv->day_name_h = (priv->max_label_char_ascent
|
||||||
+ priv->max_label_char_descent
|
+ priv->max_label_char_descent
|
||||||
+ 2 * (focus_padding + focus_width) + calendar_margin);
|
+ day_name_padding.top + day_name_padding.bottom
|
||||||
|
+ 2 * (focus_width) + calendar_margin);
|
||||||
calendar_margin = calendar_ysep;
|
calendar_margin = calendar_ysep;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2086,7 +2129,8 @@ gtk_calendar_size_request (GtkWidget *widget,
|
|||||||
+ 6 * (priv->max_day_char_ascent
|
+ 6 * (priv->max_day_char_ascent
|
||||||
+ priv->max_day_char_descent
|
+ priv->max_day_char_descent
|
||||||
+ max_detail_height
|
+ max_detail_height
|
||||||
+ 2 * (focus_padding + focus_width))
|
+ day_padding.top + day_padding.bottom
|
||||||
|
+ 2 * (focus_width))
|
||||||
+ DAY_YSEP * 5);
|
+ DAY_YSEP * 5);
|
||||||
|
|
||||||
height = priv->header_h + priv->day_name_h + priv->main_h;
|
height = priv->header_h + priv->day_name_h + priv->main_h;
|
||||||
@ -2322,8 +2366,7 @@ calendar_paint_day_names (GtkCalendar *calendar,
|
|||||||
GtkWidget *widget = GTK_WIDGET (calendar);
|
GtkWidget *widget = GTK_WIDGET (calendar);
|
||||||
GtkCalendarPrivate *priv = calendar->priv;
|
GtkCalendarPrivate *priv = calendar->priv;
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
GtkStateFlags state;
|
GtkBorder padding, day_name_padding;
|
||||||
GtkBorder padding;
|
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
char buffer[255];
|
char buffer[255];
|
||||||
int day,i;
|
int day,i;
|
||||||
@ -2331,15 +2374,13 @@ calendar_paint_day_names (GtkCalendar *calendar,
|
|||||||
int day_wid_sep;
|
int day_wid_sep;
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
PangoRectangle logical_rect;
|
PangoRectangle logical_rect;
|
||||||
gint focus_padding;
|
|
||||||
gint focus_width;
|
gint focus_width;
|
||||||
gint calendar_ysep = calendar_get_ysep (calendar);
|
gint calendar_ysep = calendar_get_ysep (calendar);
|
||||||
gint calendar_xsep = calendar_get_xsep (calendar);
|
gint calendar_xsep = calendar_get_xsep (calendar);
|
||||||
gint inner_border = calendar_get_inner_border (calendar);
|
gint inner_border = calendar_get_inner_border (calendar);
|
||||||
|
|
||||||
|
get_component_paddings (calendar, &padding, NULL, &day_name_padding, NULL);
|
||||||
context = gtk_widget_get_style_context (widget);
|
context = gtk_widget_get_style_context (widget);
|
||||||
state = gtk_widget_get_state_flags (widget);
|
|
||||||
gtk_style_context_get_padding (context, state, &padding);
|
|
||||||
|
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
|
|
||||||
@ -2349,7 +2390,6 @@ calendar_paint_day_names (GtkCalendar *calendar,
|
|||||||
|
|
||||||
gtk_widget_style_get (GTK_WIDGET (widget),
|
gtk_widget_style_get (GTK_WIDGET (widget),
|
||||||
"focus-line-width", &focus_width,
|
"focus-line-width", &focus_width,
|
||||||
"focus-padding", &focus_padding,
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
@ -2401,7 +2441,7 @@ calendar_paint_day_names (GtkCalendar *calendar,
|
|||||||
: 0)
|
: 0)
|
||||||
+ day_wid_sep * i
|
+ day_wid_sep * i
|
||||||
+ (day_width - logical_rect.width)/2),
|
+ (day_width - logical_rect.width)/2),
|
||||||
CALENDAR_MARGIN + focus_width + focus_padding + logical_rect.y,
|
CALENDAR_MARGIN + focus_width + day_name_padding.top + logical_rect.y,
|
||||||
layout);
|
layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2418,23 +2458,20 @@ calendar_paint_week_numbers (GtkCalendar *calendar,
|
|||||||
GtkWidget *widget = GTK_WIDGET (calendar);
|
GtkWidget *widget = GTK_WIDGET (calendar);
|
||||||
GtkCalendarPrivate *priv = calendar->priv;
|
GtkCalendarPrivate *priv = calendar->priv;
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
GtkStateFlags state;
|
GtkBorder padding, week_padding;
|
||||||
GtkBorder padding;
|
|
||||||
guint week = 0, year;
|
guint week = 0, year;
|
||||||
gint row, x_loc, y_loc;
|
gint row, x_loc, y_loc;
|
||||||
gint day_height;
|
gint day_height;
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
PangoRectangle logical_rect;
|
PangoRectangle logical_rect;
|
||||||
gint focus_padding;
|
|
||||||
gint focus_width;
|
gint focus_width;
|
||||||
gint calendar_xsep = calendar_get_xsep (calendar);
|
gint calendar_xsep = calendar_get_xsep (calendar);
|
||||||
gint inner_border = calendar_get_inner_border (calendar);
|
gint inner_border = calendar_get_inner_border (calendar);
|
||||||
gint x, y;
|
gint x, y;
|
||||||
|
|
||||||
|
get_component_paddings (calendar, &padding, NULL, NULL, &week_padding);
|
||||||
context = gtk_widget_get_style_context (widget);
|
context = gtk_widget_get_style_context (widget);
|
||||||
state = gtk_widget_get_state_flags (widget);
|
|
||||||
gtk_style_context_get_padding (context, state, &padding);
|
|
||||||
|
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
|
|
||||||
@ -2446,7 +2483,6 @@ calendar_paint_week_numbers (GtkCalendar *calendar,
|
|||||||
|
|
||||||
gtk_widget_style_get (GTK_WIDGET (widget),
|
gtk_widget_style_get (GTK_WIDGET (widget),
|
||||||
"focus-line-width", &focus_width,
|
"focus-line-width", &focus_width,
|
||||||
"focus-padding", &focus_padding,
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gtk_style_context_save (context);
|
gtk_style_context_save (context);
|
||||||
@ -2502,7 +2538,7 @@ calendar_paint_week_numbers (GtkCalendar *calendar,
|
|||||||
|
|
||||||
x_loc = x + (priv->week_width
|
x_loc = x + (priv->week_width
|
||||||
- logical_rect.width
|
- logical_rect.width
|
||||||
- calendar_xsep - focus_padding - focus_width);
|
- calendar_xsep - focus_width - week_padding.right);
|
||||||
|
|
||||||
gtk_render_layout (context, cr, x_loc, y_loc, layout);
|
gtk_render_layout (context, cr, x_loc, y_loc, layout);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user