gdouble *l,
gdouble *s);
+static void style_unrealize_cursor_gcs (GtkStyle *style);
/*
* Data for default check and radio buttons
CHECK_LIGHT,
CHECK_MID,
CHECK_TEXT,
+ CHECK_INCONSISTENT_AA,
+ CHECK_INCONSISTENT_TEXT,
RADIO_BASE,
RADIO_BLACK,
RADIO_DARK,
RADIO_LIGHT,
RADIO_MID,
- RADIO_TEXT
+ RADIO_TEXT,
+ RADIO_INCONSISTENT_AA,
+ RADIO_INCONSISTENT_TEXT
} IndicatorPart;
-static char check_aa_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x58,0x00,0xa0,
- 0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-static char check_base_bits[] = {
- 0x00,0x00,0x00,0x00,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
- 0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0x00,0x00,0x00,0x00};
+/*
+ * Extracted from check-13.png, width=13, height=13
+ */
static char check_black_bits[] = {
- 0x00,0x00,0xfe,0x0f,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
- 0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00};
+ 0x00,0x00,0xfe,0x0f,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
+ 0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00};
static char check_dark_bits[] = {
- 0xff,0x1f,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
- 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00};
-static char check_light_bits[] = {
- 0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
- 0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0xfe,0x1f};
+ 0xff,0x1f,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x00,0x00};
static char check_mid_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
- 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0xfc,0x0f,0x00,0x00};
+ 0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
+ 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0xfc,0x0f,0x00,0x00,0x00,0x00};
+static char check_light_bits[] = {
+ 0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
+ 0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0xfe,0x1f,0x00,0x00};
static char check_text_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x03,0x80,0x01,0x80,0x00,0xd8,
- 0x00,0x60,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-static char radio_base_bits[] = {
- 0x00,0x00,0x00,0x00,0xf0,0x01,0xf8,0x03,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
- 0x07,0xfc,0x07,0xf8,0x03,0xf0,0x01,0x00,0x00,0x00,0x00};
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x03,0x80,0x01,0x80,0x00,0x58,
+ 0x00,0x60,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+static char check_aa_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x58,0x00,0xa0,
+ 0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+static char check_base_bits[] = {
+ 0x00,0x00,0x00,0x00,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
+ 0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0x00,0x00,0x00,0x00,0x00,0x00};
+
+/*
+ * Extracted from check-13-inconsistent-ssp.png, width=13, height=13
+ */
+static char check_inconsistent_text_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x03,0xf8,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+static char check_inconsistent_aa_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+
+/*
+ * Extracted from radio-13-ssp.png, width=13, height=13
+ */
static char radio_black_bits[] = {
- 0x00,0x00,0xf0,0x01,0x08,0x02,0x04,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
- 0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+ 0x00,0x00,0xf0,0x01,0x0c,0x02,0x04,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
+ 0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static char radio_dark_bits[] = {
- 0xf0,0x01,0x08,0x02,0x04,0x04,0x02,0x04,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
- 0x00,0x01,0x00,0x02,0x00,0x0c,0x00,0x00,0x00,0x00,0x00};
-static char radio_light_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
- 0x10,0x00,0x10,0x00,0x08,0x00,0x04,0x08,0x02,0xf0,0x01};
+ 0xf0,0x00,0x0c,0x02,0x02,0x04,0x02,0x04,0x01,0x08,0x01,0x08,0x01,0x08,0x01,
+ 0x08,0x00,0x04,0x02,0x04,0x0c,0x03,0xf0,0x00,0x00,0x00,0x00,0x00};
static char radio_mid_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
- 0x08,0x00,0x08,0x00,0x04,0x00,0x02,0xf0,0x01,0x00,0x00};
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+static char radio_light_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
+ 0x10,0x00,0x08,0x00,0x08,0x00,0x04,0x00,0x03,0xf0,0x00,0x00,0x00};
static char radio_text_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00,0xf0,0x01,0xf0,0x01,0xf0,
- 0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00,0xf0,0x01,0xf0,0x01,0xf0,
+ 0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+static char radio_aa_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+static char radio_base_bits[] = {
+ 0x00,0x00,0x00,0x00,0xf0,0x01,0xf8,0x03,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
+ 0x07,0xfc,0x03,0xf8,0x03,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+/*
+ * Extracted from radio-13-inconsistent-ssp.png, width=13, height=13
+ */
+static char radio_inconsistent_text_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x03,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+static char radio_inconsistent_aa_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x03,0x00,0x00,0xf8,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static struct {
char *bits;
{ check_light_bits, NULL },
{ check_mid_bits, NULL },
{ check_text_bits, NULL },
+ { check_inconsistent_aa_bits, NULL },
+ { check_inconsistent_text_bits, NULL },
{ radio_base_bits, NULL },
{ radio_black_bits, NULL },
{ radio_dark_bits, NULL },
{ radio_light_bits, NULL },
{ radio_mid_bits, NULL },
- { radio_text_bits, NULL }
+ { radio_text_bits, NULL },
+ { radio_inconsistent_aa_bits, NULL },
+ { radio_inconsistent_text_bits, NULL },
};
/* --- variables --- */
gtk_style_init (GtkStyle *style)
{
gint i;
-
- style->font_desc = pango_font_description_from_string ("Sans 10");
+ const gchar *font_name = _gtk_rc_context_get_default_font_name (gtk_settings_get_default ());
+ style->font_desc = pango_font_description_from_string (font_name);
+
+ if (!pango_font_description_get_family (style->font_desc))
+ {
+ g_warning ("Default font does not have a family set");
+ pango_font_description_set_family (style->font_desc, "Sans");
+ }
+ if (pango_font_description_get_size (style->font_desc) <= 0)
+ {
+ g_warning ("Default font does not have a positive size");
+ pango_font_description_set_size (style->font_desc, 10 * PANGO_SCALE);
+ }
+
style->attach_count = 0;
style->colormap = NULL;
style->depth = -1;
gdk_colormap_free_colors (style->colormap, style->text, 5);
gdk_colormap_free_colors (style->colormap, style->base, 5);
gdk_colormap_free_colors (style->colormap, style->text_aa, 5);
+
+ style_unrealize_cursor_gcs (style);
}
static void
}
static void
-draw_spinbutton_shadow (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state,
- GdkRectangle *area,
- gint x,
- gint y,
- gint width,
- gint height)
+draw_spinbutton_shadow (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state,
+ GtkTextDirection direction,
+ GdkRectangle *area,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
- gint y_middle = y + height / 2;
-
sanitize_size (window, &width, &height);
-
+
if (area)
{
gdk_gc_set_clip_rectangle (style->black_gc, area);
gdk_gc_set_clip_rectangle (style->dark_gc[state], area);
gdk_gc_set_clip_rectangle (style->light_gc[state], area);
}
-
- gdk_draw_line (window, style->black_gc,
- x, y + 2, x, y + height - 3);
- gdk_draw_line (window, style->black_gc,
- x, y + 1, x + width - 2, y + 1);
- gdk_draw_line (window, style->black_gc,
- x + width - 2, y + 2, x + width - 2, y + height - 3);
-
- gdk_draw_line (window, style->bg_gc[state],
- x, y + height - 2, x + width - 2, y + height - 2);
-
- gdk_draw_line (window, style->dark_gc[state],
- x, y, x + width - 1, y);
- gdk_draw_line (window, style->dark_gc[state],
- x + 1, y_middle - 1, x + width - 3, y_middle - 1);
- gdk_draw_line (window, style->dark_gc[state],
- x + 1, y + height - 3, x + width - 3, y + height - 3);
- gdk_draw_line (window, style->light_gc[state],
- x + 1, y + 2, x + width - 3, y + 2);
- gdk_draw_line (window, style->light_gc[state],
- x + 1, y_middle, x + width - 3, y_middle);
- gdk_draw_line (window, style->light_gc[state],
- x + width - 1, y + 1, x + width - 1, y + height - 1);
- gdk_draw_line (window, style->light_gc[state],
- x, y + height - 1, x + width - 2, y + height - 1);
-
+ if (direction == GTK_TEXT_DIR_LTR)
+ {
+ gdk_draw_line (window, style->dark_gc[state],
+ x, y, x + width - 1, y);
+ gdk_draw_line (window, style->black_gc,
+ x, y + 1, x + width - 2, y + 1);
+ gdk_draw_line (window, style->black_gc,
+ x + width - 2, y + 2, x + width - 2, y + height - 3);
+ gdk_draw_line (window, style->light_gc[state],
+ x + width - 1, y + 1, x + width - 1, y + height - 2);
+ gdk_draw_line (window, style->light_gc[state],
+ x, y + height - 1, x + width - 1, y + height - 1);
+ gdk_draw_line (window, style->bg_gc[state],
+ x, y + height - 2, x + width - 2, y + height - 2);
+ gdk_draw_line (window, style->black_gc,
+ x, y + 2, x, y + height - 3);
+ }
+ else
+ {
+ gdk_draw_line (window, style->dark_gc[state],
+ x, y, x + width - 1, y);
+ gdk_draw_line (window, style->dark_gc[state],
+ x, y + 1, x, y + height - 1);
+ gdk_draw_line (window, style->black_gc,
+ x + 1, y + 1, x + width - 1, y + 1);
+ gdk_draw_line (window, style->black_gc,
+ x + 1, y + 2, x + 1, y + height - 2);
+ gdk_draw_line (window, style->black_gc,
+ x + width - 1, y + 2, x + width - 1, y + height - 3);
+ gdk_draw_line (window, style->light_gc[state],
+ x + 1, y + height - 1, x + width - 1, y + height - 1);
+ gdk_draw_line (window, style->bg_gc[state],
+ x + 2, y + height - 2, x + width - 1, y + height - 2);
+ }
+
if (area)
{
gdk_gc_set_clip_rectangle (style->black_gc, NULL);
x, y, width, height);
return;
}
- else if (widget && GTK_IS_SPIN_BUTTON (widget) &&
- detail && strcmp (detail, "entry") == 0)
- {
- draw_spin_entry_shadow (style, window, state_type, area,
- x, y, width, height);
- return;
- }
- else if (widget && GTK_IS_SPIN_BUTTON (widget) &&
- detail && strcmp (detail, "spinbutton") == 0)
+ if (widget && GTK_IS_SPIN_BUTTON (widget) &&
+ detail && strcmp (detail, "spinbutton") == 0)
{
draw_spinbutton_shadow (style, window, state_type,
- area, x, y, width, height);
+ gtk_widget_get_direction (widget), area, x, y, width, height);
+
return;
}
}
break;
}
+
+ if (shadow_type == GTK_SHADOW_IN &&
+ widget && GTK_IS_SPIN_BUTTON (widget) &&
+ detail && strcmp (detail, "entry") == 0)
+ {
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
+ {
+ gdk_draw_line (window,
+ style->base_gc[state_type],
+ x + width - 1, y + 2,
+ x + width - 1, y + height - 3);
+ gdk_draw_line (window,
+ style->base_gc[state_type],
+ x + width - 2, y + 2,
+ x + width - 2, y + height - 3);
+ gdk_draw_point (window,
+ style->black_gc,
+ x + width - 1, y + 1);
+ gdk_draw_point (window,
+ style->bg_gc[state_type],
+ x + width - 1, y + height - 2);
+ }
+ else
+ {
+ gdk_draw_line (window,
+ style->base_gc[state_type],
+ x, y + 2,
+ x, y + height - 3);
+ gdk_draw_line (window,
+ style->base_gc[state_type],
+ x + 1, y + 2,
+ x + 1, y + height - 3);
+ gdk_draw_point (window,
+ style->black_gc,
+ x, y + 1);
+ gdk_draw_line (window,
+ style->bg_gc[state_type],
+ x, y + height - 2,
+ x + 1, y + height - 2);
+ gdk_draw_point (window,
+ style->light_gc[state_type],
+ x, y + height - 1);
+ }
+ }
+
+
if (area)
{
gdk_gc_set_clip_rectangle (gc1, NULL);
}
static void
-draw_varrow (GdkWindow *window,
- GdkGC *gc,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkArrowType arrow_type,
- gint x,
- gint y,
- gint width,
- gint height)
+draw_arrow (GdkWindow *window,
+ GdkGC *gc,
+ GdkRectangle *area,
+ GtkArrowType arrow_type,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
- gint steps, extra;
- gint y_start, y_increment;
- gint i;
+ gint i, j;
if (area)
gdk_gc_set_clip_rectangle (gc, area);
-
- width = width + width % 2 - 1; /* Force odd */
-
- steps = 1 + width / 2;
-
- extra = height - steps;
if (arrow_type == GTK_ARROW_DOWN)
{
- y_start = y;
- y_increment = 1;
+ for (i = 0, j = 0; i < height; i++, j++)
+ gdk_draw_line (window, gc, x + j, y + i, x + width - j - 1, y + i);
}
- else
+ else if (arrow_type == GTK_ARROW_UP)
{
- y_start = y + height - 1;
- y_increment = -1;
+ for (i = height - 1, j = 0; i >= 0; i--, j++)
+ gdk_draw_line (window, gc, x + j, y + i, x + width - j - 1, y + i);
}
-
- for (i = 0; i < extra; i++)
+ else if (arrow_type == GTK_ARROW_LEFT)
{
- gdk_draw_line (window, gc,
- x, y_start + i * y_increment,
- x + width - 1, y_start + i * y_increment);
+ for (i = width - 1, j = 0; i >= 0; i--, j++)
+ gdk_draw_line (window, gc, x + i, y + j, x + i, y + height - j - 1);
}
- for (; i < height; i++)
+ else if (arrow_type == GTK_ARROW_RIGHT)
{
- gdk_draw_line (window, gc,
- x + (i - extra), y_start + i * y_increment,
- x + width - (i - extra) - 1, y_start + i * y_increment);
+ for (i = 0, j = 0; i < width; i++, j++)
+ gdk_draw_line (window, gc, x + i, y + j, x + i, y + height - j - 1);
}
-
if (area)
gdk_gc_set_clip_rectangle (gc, NULL);
}
static void
-draw_harrow (GdkWindow *window,
- GdkGC *gc,
- GtkShadowType shadow_type,
- GdkRectangle *area,
- GtkArrowType arrow_type,
- gint x,
- gint y,
- gint width,
- gint height)
+calculate_arrow_geometry (GtkArrowType arrow_type,
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height)
{
- gint steps, extra;
- gint x_start, x_increment;
- gint i;
-
- if (area)
- gdk_gc_set_clip_rectangle (gc, area);
+ gint w = *width;
+ gint h = *height;
- height = height + height % 2 - 1; /* Force odd */
-
- steps = 1 + height / 2;
-
- extra = width - steps;
-
- if (arrow_type == GTK_ARROW_RIGHT)
+ switch (arrow_type)
{
- x_start = x;
- x_increment = 1;
- }
- else
- {
- x_start = x + width - 1;
- x_increment = -1;
- }
+ case GTK_ARROW_UP:
+ case GTK_ARROW_DOWN:
+ w += (w % 2) - 1;
+ h = (w / 2 + 1);
+
+ if (h > *height)
+ {
+ h = *height;
+ w = 2 * h - 1;
+ }
+
+ if (arrow_type == GTK_ARROW_DOWN)
+ {
+ if (*height % 2 == 1 || h % 2 == 0)
+ *height += 1;
+ }
+ else
+ {
+ if (*height % 2 == 0 || h % 2 == 0)
+ *height -= 1;
+ }
+ break;
- for (i = 0; i < extra; i++)
- {
- gdk_draw_line (window, gc,
- x_start + i * x_increment, y,
- x_start + i * x_increment, y + height - 1);
- }
- for (; i < width; i++)
- {
- gdk_draw_line (window, gc,
- x_start + i * x_increment, y + (i - extra),
- x_start + i * x_increment, y + height - (i - extra) - 1);
+ case GTK_ARROW_RIGHT:
+ case GTK_ARROW_LEFT:
+ h += (h % 2) - 1;
+ w = (h / 2 + 1);
+
+ if (w > *width)
+ {
+ w = *width;
+ h = 2 * w - 1;
+ }
+
+ if (arrow_type == GTK_ARROW_RIGHT)
+ {
+ if (*width % 2 == 1 || w % 2 == 0)
+ *width += 1;
+ }
+ else
+ {
+ if (*width % 2 == 0 || w % 2 == 0)
+ *width -= 1;
+ }
+ break;
+
+ default:
+ /* should not be reached */
+ break;
}
-
- if (area)
- gdk_gc_set_clip_rectangle (gc, NULL);
+ *x += (*width - w) / 2;
+ *y += (*height - h) / 2;
+ *height = h;
+ *width = w;
}
static void
gint width,
gint height)
{
- sanitize_size (window, &width, &height);
+ gint original_width, original_x;
- if (detail && strcmp (detail, "spinbutton") == 0)
- {
- int hpad, vpad;
- int my_height = height;
- int my_width = width;
- int vpad_add = 0;
-
- if (my_height > my_width)
- {
- vpad_add = (my_height - my_width) / 2;
- my_height = my_width;
- }
-
- hpad = my_width / 4;
-
- if (hpad < 4)
- hpad = 4;
-
- vpad = 2 * hpad - 1;
-
- x += hpad / 2;
- y += vpad / 2;
+ sanitize_size (window, &width, &height);
- y += vpad_add;
+ original_width = width;
+ original_x = x;
- draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
- x, y, my_width - hpad, my_height - vpad);
- }
- else if (detail && strcmp (detail, "vscrollbar") == 0)
- {
- gtk_paint_box (style, window, state, shadow, area,
- widget, detail, x, y, width, height);
-
- x += (width - 7) / 2;
- y += (height - 5) / 2;
-
- draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
- x, y, 7, 5);
- }
- else if (detail && strcmp (detail, "hscrollbar") == 0)
- {
- gtk_paint_box (style, window, state, shadow, area,
- widget, detail, x, y, width, height);
-
- y += (height - 7) / 2;
- x += (width - 5) / 2;
+ calculate_arrow_geometry (arrow_type, &x, &y, &width, &height);
+
+ if (detail && strcmp (detail, "menuitem") == 0)
+ x = original_x + original_width - width;
- draw_harrow (window, style->fg_gc[state], shadow, area, arrow_type,
- x, y, 5, 7);
- }
- else
- {
- if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN)
- {
- x += (width - 7) / 2;
- y += (height - 5) / 2;
-
- draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
- x, y, 7, 5);
- }
- else
- {
- x += (width - 5) / 2;
- y += (height - 7) / 2;
-
- draw_harrow (window, style->fg_gc[state], shadow, area, arrow_type,
- x, y, 5, 7);
- }
- }
+ if (state == GTK_STATE_INSENSITIVE)
+ draw_arrow (window, style->white_gc, area, arrow_type,
+ x + 1, y + 1, width, height);
+ draw_arrow (window, style->fg_gc[state], area, arrow_type,
+ x, y, width, height);
}
static void
gint width,
gint height)
{
+ gboolean is_spinbutton_box = FALSE;
+
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
sanitize_size (window, &width, &height);
+
+ if (widget && GTK_IS_SPIN_BUTTON (widget) && detail)
+ {
+ if (strcmp (detail, "spinbutton_up") == 0)
+ {
+ y += 2;
+ width -= 3;
+ height -= 2;
+
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+ x += 2;
+ else
+ x += 1;
+
+ is_spinbutton_box = TRUE;
+ }
+ else if (strcmp (detail, "spinbutton_down") == 0)
+ {
+ width -= 3;
+ height -= 2;
+
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+ x += 2;
+ else
+ x += 1;
+
+ is_spinbutton_box = TRUE;
+ }
+ }
if (!style->bg_pixmap[state_type] ||
GDK_IS_PIXMAP (window))
gtk_style_apply_default_background (style, window,
widget && !GTK_WIDGET_NO_WINDOW (widget),
state_type, area, x, y, width, height);
-
+
+ if (is_spinbutton_box)
+ {
+ GdkGC *upper_gc;
+ GdkGC *lower_gc;
+
+ lower_gc = style->dark_gc[state_type];
+ if (shadow_type == GTK_SHADOW_OUT)
+ upper_gc = style->light_gc[state_type];
+ else
+ upper_gc = style->dark_gc[state_type];
+
+ if (area)
+ {
+ gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
+ gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
+ }
+
+ gdk_draw_line (window, upper_gc, x, y, x + width - 1, y);
+ gdk_draw_line (window, lower_gc, x, y + height - 1, x + width - 1, y + height - 1);
+
+ if (area)
+ {
+ gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
+ gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
+ }
+ return;
+ }
+
gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
x, y, width, height);
draw_part (window, style->black_gc, area, x, y, CHECK_TEXT);
draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_AA);
}
+ else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
+ {
+ draw_part (window, style->black_gc, area, x, y, CHECK_INCONSISTENT_TEXT);
+ draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_INCONSISTENT_AA);
+ }
}
else
{
+ GdkGC *base_gc = style->base_gc[state_type];
+
+ if (state_type == GTK_STATE_ACTIVE)
+ base_gc = style->bg_gc[GTK_STATE_ACTIVE];
+
+ draw_part (window, base_gc, area, x, y, CHECK_BASE);
draw_part (window, style->black_gc, area, x, y, CHECK_BLACK);
draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_DARK);
draw_part (window, style->mid_gc[state_type], area, x, y, CHECK_MID);
draw_part (window, style->light_gc[state_type], area, x, y, CHECK_LIGHT);
- draw_part (window, style->base_gc[state_type], area, x, y, CHECK_BASE);
if (shadow_type == GTK_SHADOW_IN)
{
draw_part (window, style->text_gc[state_type], area, x, y, CHECK_TEXT);
draw_part (window, style->text_aa_gc[state_type], area, x, y, CHECK_AA);
}
+ else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
+ {
+ draw_part (window, style->text_gc[state_type], area, x, y, CHECK_INCONSISTENT_TEXT);
+ draw_part (window, style->text_aa_gc[state_type], area, x, y, CHECK_INCONSISTENT_AA);
+ }
}
}
if (strcmp (detail, "option") == 0) /* Menu item */
{
if (shadow_type == GTK_SHADOW_IN)
- draw_part (window, style->fg_gc[state_type], area, x, y, RADIO_TEXT);
+ {
+ draw_part (window, style->fg_gc[state_type], area, x, y, RADIO_TEXT);
+ }
+ else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
+ {
+ draw_part (window, style->black_gc, area, x, y, CHECK_INCONSISTENT_TEXT);
+ draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_INCONSISTENT_AA);
+ }
}
else
{
+ GdkGC *base_gc = style->base_gc[state_type];
+
+ if (state_type == GTK_STATE_ACTIVE)
+ base_gc = style->bg_gc[GTK_STATE_ACTIVE];
+
+ draw_part (window, base_gc, area, x, y, RADIO_BASE);
draw_part (window, style->black_gc, area, x, y, RADIO_BLACK);
draw_part (window, style->dark_gc[state_type], area, x, y, RADIO_DARK);
draw_part (window, style->mid_gc[state_type], area, x, y, RADIO_MID);
draw_part (window, style->light_gc[state_type], area, x, y, RADIO_LIGHT);
- draw_part (window, style->base_gc[state_type], area, x, y, RADIO_BASE);
if (shadow_type == GTK_SHADOW_IN)
- draw_part (window, style->text_gc[state_type], area, x, y, RADIO_TEXT);
+ {
+ draw_part (window, style->text_gc[state_type], area, x, y, RADIO_TEXT);
+ }
+ else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
+ {
+ draw_part (window, style->text_aa_gc[state_type], area, x, y, RADIO_INCONSISTENT_AA);
+ draw_part (window, style->text_gc[state_type], area, x, y, RADIO_INCONSISTENT_TEXT);
+ }
}
}
}
gint width,
gint height)
{
+#define ARROW_SPACE 4
+
GtkRequisition indicator_size;
GtkBorder indicator_spacing;
+ gint arrow_height;
option_menu_get_props (widget, &indicator_size, &indicator_spacing);
+ indicator_size.width += (indicator_size.width % 2) - 1;
+ arrow_height = indicator_size.width / 2 + 1;
+
x += (width - indicator_size.width) / 2;
- y += (height - indicator_size.height) / 2 - 1;
+ y += (height - (2 * arrow_height + ARROW_SPACE)) / 2;
- draw_varrow (window, style->black_gc, shadow_type, area, GTK_ARROW_UP,
- x, y, indicator_size.width, 5);
- draw_varrow (window, style->black_gc, shadow_type, area, GTK_ARROW_DOWN,
- x, y + 8, indicator_size.width, 5);
+ if (state_type == GTK_STATE_INSENSITIVE)
+ {
+ draw_arrow (window, style->white_gc, area,
+ GTK_ARROW_UP, x + 1, y + 1,
+ indicator_size.width, arrow_height);
+
+ draw_arrow (window, style->white_gc, area,
+ GTK_ARROW_DOWN, x + 1, y + arrow_height + ARROW_SPACE + 1,
+ indicator_size.width, arrow_height);
+ }
+
+ draw_arrow (window, style->fg_gc[state_type], area,
+ GTK_ARROW_UP, x, y,
+ indicator_size.width, arrow_height);
+
+
+ draw_arrow (window, style->fg_gc[state_type], area,
+ GTK_ARROW_DOWN, x, y + arrow_height + ARROW_SPACE,
+ indicator_size.width, arrow_height);
}
static void
g_free (border);
}
+GType
+gtk_border_get_type (void)
+{
+ static GType our_type = 0;
+
+ if (our_type == 0)
+ our_type = g_boxed_type_register_static ("GtkTypeBorder",
+ (GBoxedCopyFunc) gtk_border_copy,
+ (GBoxedFreeFunc) gtk_border_free);
+
+ return our_type;
+}
+
/**
* gtk_style_get_font:
* @style: a #GtkStyle
}
}
+typedef struct _CursorInfo CursorInfo;
+
+struct _CursorInfo
+{
+ GType for_type;
+ GdkGC *primary_gc;
+ GdkGC *secondary_gc;
+};
+
+static void
+style_unrealize_cursor_gcs (GtkStyle *style)
+{
+ CursorInfo *
+
+ cursor_info = g_object_get_data (G_OBJECT (style), "gtk-style-cursor-info");
+ if (cursor_info)
+ {
+ if (cursor_info->primary_gc)
+ gtk_gc_release (cursor_info->primary_gc);
+
+ if (cursor_info->secondary_gc)
+ gtk_gc_release (cursor_info->secondary_gc);
+
+ g_free (cursor_info);
+ g_object_set_data (G_OBJECT (style), "gtk-style-cursor-info", NULL);
+ }
+}
+
+static GdkGC *
+make_cursor_gc (GtkWidget *widget,
+ const gchar *property_name,
+ GdkColor *fallback)
+{
+ GdkGCValues gc_values;
+ GdkGCValuesMask gc_values_mask;
+ GdkColor *cursor_color;
+
+ gtk_widget_style_get (widget, property_name, &cursor_color, NULL);
+
+ gc_values_mask = GDK_GC_FOREGROUND;
+ if (cursor_color)
+ {
+ gc_values.foreground = *cursor_color;
+ gdk_color_free (cursor_color);
+ }
+ else
+ gc_values.foreground = *fallback;
+
+ gdk_rgb_find_color (widget->style->colormap, &gc_values.foreground);
+ return gtk_gc_get (widget->style->depth, widget->style->colormap, &gc_values, gc_values_mask);
+}
+
+/**
+ * _gtk_get_insertion_cursor_gc:
+ * @widget: a #GtkWidget
+ * @is_primary: if the cursor should be the primary cursor color.
+ *
+ * Get a GC suitable for drawing the primary or secondary text
+ * cursor.
+ *
+ * Note: the return value is ref'ed because calls to this function
+ * on other widgets could result in this the GC being released
+ * which would be an unexpected side effect. If made public,
+ * this function should possibly be called create_insertion_cursor_gc().
+ *
+ * Return value: an appropriate #GdkGC. Call g_object_unref() on
+ * the gc when you are done with it; this GC may be shared with
+ * other users, so you must not modify the GC except for temporarily
+ * setting the clip before drawing with the GC, and then unsetting the clip
+ * again afterwards.
+ **/
+GdkGC *
+_gtk_get_insertion_cursor_gc (GtkWidget *widget,
+ gboolean is_primary)
+{
+ CursorInfo *cursor_info;
+
+ cursor_info = g_object_get_data (G_OBJECT (widget->style), "gtk-style-cursor-info");
+ if (!cursor_info)
+ {
+ cursor_info = g_new (CursorInfo, 1);
+ g_object_set_data (G_OBJECT (widget->style), "gtk-style-cursor-info", cursor_info);
+ cursor_info->primary_gc = NULL;
+ cursor_info->secondary_gc = NULL;
+ cursor_info->for_type = G_TYPE_INVALID;
+ }
+
+ /* We have to keep track of the type because gtk_widget_style_get()
+ * can return different results when called on the same property and
+ * same style but for different widgets. :-(. That is,
+ * GtkEntry::cursor-color = "red" in a style will modify the cursor
+ * color for entries but not for text view.
+ */
+ if (cursor_info->for_type != G_OBJECT_TYPE (widget))
+ {
+ cursor_info->for_type = G_OBJECT_TYPE (widget);
+ if (cursor_info->primary_gc)
+ {
+ gtk_gc_release (cursor_info->primary_gc);
+ cursor_info->primary_gc = NULL;
+ }
+ if (cursor_info->secondary_gc)
+ {
+ gtk_gc_release (cursor_info->secondary_gc);
+ cursor_info->secondary_gc = NULL;
+ }
+ }
+
+ if (is_primary)
+ {
+ if (!cursor_info->primary_gc)
+ cursor_info->primary_gc = make_cursor_gc (widget,
+ "cursor-color",
+ &widget->style->black);
+
+ return g_object_ref (cursor_info->primary_gc);
+ }
+ else
+ {
+ static GdkColor gray = { 0, 0x8888, 0x8888, 0x8888 };
+
+ if (!cursor_info->secondary_gc)
+ cursor_info->secondary_gc = make_cursor_gc (widget,
+ "secondary-cursor-color",
+ &gray);
+
+ return g_object_ref (cursor_info->secondary_gc);
+ }
+}
+
/**
* _gtk_draw_insertion_cursor:
* @widget: a #GtkWidget
* @drawable: a #GdkDrawable
* @gc: a #GdkGC
* @location: location where to draw the cursor (@location->width is ignored)
- * @dir: text direction for the cursor, used to decide whether to draw a
- * directional arrow on the cursor and in what direction. Unless both
- * strong and weak cursors are displayed, this should be %GTK_TEXT_DIR_NONE.
+ * @direction: whether the cursor is left-to-right or
+ * right-to-left. Should never be #GTK_TEXT_DIR_NONE
+ * @draw_arrow: %TRUE to draw a directional arrow on the
+ * cursor. Should be %FALSE unless the cursor is split.
*
* Draws a text caret on @drawable at @location. This is not a style function
* but merely a convenience function for drawing the standard cursor shape.
GdkDrawable *drawable,
GdkGC *gc,
GdkRectangle *location,
- GtkTextDirection dir)
+ GtkTextDirection direction,
+ gboolean draw_arrow)
{
gint stem_width;
gint arrow_width;
gint x, y;
gint i;
gfloat cursor_aspect_ratio;
-
+ gint offset;
+
+ g_return_if_fail (direction != GTK_TEXT_DIR_NONE);
+
gtk_widget_style_get (widget, "cursor-aspect-ratio", &cursor_aspect_ratio, NULL);
stem_width = location->height * cursor_aspect_ratio + 1;
arrow_width = stem_width + 1;
-
+
+ /* put (stem_width % 2) on the proper side of the cursor */
+ if (direction == GTK_TEXT_DIR_LTR)
+ offset = stem_width / 2;
+ else
+ offset = stem_width - stem_width / 2;
+
for (i = 0; i < stem_width; i++)
gdk_draw_line (drawable, gc,
- location->x + i - stem_width / 2, location->y,
- location->x + i - stem_width / 2, location->y + location->height);
+ location->x + i - offset, location->y,
+ location->x + i - offset, location->y + location->height - 1);
- if (dir == GTK_TEXT_DIR_RTL)
+ if (draw_arrow)
{
- x = location->x - stem_width / 2 - 1;
- y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
+ if (direction == GTK_TEXT_DIR_RTL)
+ {
+ x = location->x - offset - 1;
+ y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
- for (i = 0; i < arrow_width; i++)
- {
- gdk_draw_line (drawable, gc,
- x, y + i + 1,
- x, y + 2 * arrow_width - i - 1);
- x --;
- }
- }
- else if (dir == GTK_TEXT_DIR_LTR)
- {
- x = location->x + stem_width - stem_width / 2;
- y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
+ for (i = 0; i < arrow_width; i++)
+ {
+ gdk_draw_line (drawable, gc,
+ x, y + i + 1,
+ x, y + 2 * arrow_width - i - 1);
+ x --;
+ }
+ }
+ else if (direction == GTK_TEXT_DIR_LTR)
+ {
+ x = location->x + stem_width - offset;
+ y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
- for (i = 0; i < arrow_width; i++)
- {
- gdk_draw_line (drawable, gc,
- x, y + i + 1,
- x, y + 2 * arrow_width - i - 1);
- x++;
- }
+ for (i = 0; i < arrow_width; i++)
+ {
+ gdk_draw_line (drawable, gc,
+ x, y + i + 1,
+ x, y + 2 * arrow_width - i - 1);
+ x++;
+ }
+ }
}
}