diff --git a/themes/pixmap_theme_draw.c b/themes/pixmap_theme_draw.c new file mode 100644 index 0000000000..cb45fdefe8 --- /dev/null +++ b/themes/pixmap_theme_draw.c @@ -0,0 +1,2842 @@ +#include "pixmap_theme.h" + +extern GtkStyleClass th_default_class; +extern GdkFont *default_font; +extern GSList *unattached_styles; + + +/* Theme functions to export */ +GtkStyle* +gtk_style_new (void); +void +gtk_style_set_background (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type); + +/* internal functions */ +void +draw_hline (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x1, + gint x2, + gint y); +void +draw_vline (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint y1, + gint y2, + gint x); +void +draw_shadow (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); + +void +draw_polygon (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GdkPoint *point, + gint npoints, + gint fill); +void +draw_arrow (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GtkArrowType arrow_type, + gint fill, + gint x, + gint y, + gint width, + gint height); +void +draw_diamond (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void +draw_oval (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void +draw_string (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + const gchar *string); +void +draw_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void +draw_flat_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void +draw_check (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void +draw_option (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void +draw_cross (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void +draw_ramp (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GtkArrowType arrow_type, + gint x, + gint y, + gint width, + gint height); +void +draw_tab (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void +draw_shadow_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + gint gap_side, + gint gap_x, + gint gap_width); +void +draw_box_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + gint gap_side, + gint gap_x, + gint gap_width); +void +draw_extension (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + gint gap_side); +void +draw_focus (GtkStyle *style, + GdkWindow *window, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void +draw_slider (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation); +void +draw_entry (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void +draw_handle (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation); + +/* internal data structs */ + +GtkStyleClass th_default_class = +{ + 2, + 2, + draw_hline, + draw_vline, + draw_shadow, + draw_polygon, + draw_arrow, + draw_diamond, + draw_oval, + draw_string, + draw_box, + draw_flat_box, + draw_check, + draw_option, + draw_cross, + draw_ramp, + draw_tab, + draw_shadow_gap, + draw_box_gap, + draw_extension, + draw_focus, + draw_slider, + draw_entry, + draw_handle +}; + +static GdkImlibImage * +load_image (char *name) +{ + static char *themedir = NULL; + char buf[1024]; + + if (!themedir) + { + char buf2[1024]; + g_snprintf (buf2, 1024, "%s/themes/", getenv("HOME")); + themedir = g_strdup (buf2); + } + + strcpy (buf, themedir); + strncat (buf, name, 1023); + buf[1023] = '\0'; + + return gdk_imlib_load_image(buf); +} + +void +draw_hline (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x1, + gint x2, + gint y) +{ + gint thickness_light; + gint thickness_dark; + gint i; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + thickness_light = style->klass->ythickness / 2; + thickness_dark = style->klass->ythickness - thickness_light; + + if (area) + { + gdk_gc_set_clip_rectangle (style->light_gc[state_type], area); + gdk_gc_set_clip_rectangle (style->black_gc, area); + } + for (i = 0; i < thickness_dark; i++) + { + gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i); +/* gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);*/ + gdk_draw_line (window, style->black_gc, x1, y + i, x2 - i - 1, y + i); + } + + y += thickness_dark; + for (i = 0; i < thickness_light; i++) + { +/* gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);*/ + gdk_draw_line (window, style->black_gc, x1, y + i, x1 + thickness_light - i - 1, y + i); + gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i); + } + if (area) + { + gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL); + gdk_gc_set_clip_rectangle (style->black_gc, NULL); + } +} + +void +draw_vline (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint y1, + gint y2, + gint x) +{ + gint thickness_light; + gint thickness_dark; + gint i; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + thickness_light = style->klass->xthickness / 2; + thickness_dark = style->klass->xthickness - thickness_light; + + if (area) + { + gdk_gc_set_clip_rectangle (style->light_gc[state_type], area); + gdk_gc_set_clip_rectangle (style->black_gc, area); + } + for (i = 0; i < thickness_dark; i++) + { + gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2); +/* gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);*/ + gdk_draw_line (window, style->black_gc, x + i, y1, x + i, y2 - i - 1); + } + + x += thickness_dark; + for (i = 0; i < thickness_light; i++) + { +/* gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);*/ + gdk_draw_line (window, style->black_gc, x + i, y1, x + i, y1 + thickness_light - i); + gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2); + } + if (area) + { + gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL); + gdk_gc_set_clip_rectangle (style->black_gc, NULL); + } +} + + +void +draw_shadow (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + GdkGC *gc1; + GdkGC *gc2; + gint thickness_light; + gint thickness_dark; + gint i; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if ((width == -1) && (height == -1)) + gdk_window_get_size (window, &width, &height); + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + switch (shadow_type) + { + case GTK_SHADOW_NONE: + gc1 = NULL; + gc2 = NULL; + break; + case GTK_SHADOW_IN: + case GTK_SHADOW_ETCHED_IN: + gc1 = style->light_gc[state_type]; + gc2 = style->black_gc; +/* gc2 = style->dark_gc[state_type];*/ + break; + case GTK_SHADOW_OUT: + case GTK_SHADOW_ETCHED_OUT: +/* gc1 = style->dark_gc[state_type];*/ + gc1 = style->black_gc; + gc2 = style->light_gc[state_type]; + break; + } + if (area) + { + gdk_gc_set_clip_rectangle (gc1, area); + gdk_gc_set_clip_rectangle (gc2, area); + } + + switch (shadow_type) + { + case GTK_SHADOW_NONE: + break; + + case GTK_SHADOW_IN: + gdk_draw_line (window, gc1, + x, y + height - 1, x + width - 1, y + height - 1); + gdk_draw_line (window, gc1, + x + width - 1, y, x + width - 1, y + height - 1); + + gdk_draw_line (window, gc1, + x + 1, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, gc1, + x + width - 2, y + 1, x + width - 2, y + height - 2); +/* + gdk_draw_line (window, style->bg_gc[state_type], + x + 1, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, style->bg_gc[state_type], + x + width - 2, y + 1, x + width - 2, y + height - 2); +*/ + gdk_draw_line (window, gc2, + x + 1, y + 1, x + width - 2, y + 1); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + 1, y + height - 2); +/* + gdk_draw_line (window, style->black_gc, + x + 1, y + 1, x + width - 2, y + 1); + gdk_draw_line (window, style->black_gc, + x + 1, y + 1, x + 1, y + height - 2); +*/ + gdk_draw_line (window, gc2, + x, y, x + width - 1, y); + gdk_draw_line (window, gc2, + x, y, x, y + height - 1); + break; + + case GTK_SHADOW_OUT: + gdk_draw_line (window, gc1, + x + 1, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, gc1, + x + width - 2, y + 1, x + width - 2, y + height - 2); + + gdk_draw_line (window, gc2, + x, y, x + width - 1, y); + gdk_draw_line (window, gc2, + x, y, x, y + height - 1); + + gdk_draw_line (window, gc2, + x + 1, y + 1, x + width - 2, y + 1); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + 1, y + height - 2); + + gdk_draw_line (window, gc1, + x, y + height - 1, x + width - 1, y + height - 1); + gdk_draw_line (window, gc1, + x + width - 1, y, x + width - 1, y + height - 1); +/* + gdk_draw_line (window, style->bg_gc[state_type], + x + 1, y + 1, x + width - 2, y + 1); + gdk_draw_line (window, style->bg_gc[state_type], + x + 1, y + 1, x + 1, y + height - 2); + + gdk_draw_line (window, style->black_gc, + x, y + height - 1, x + width - 1, y + height - 1); + gdk_draw_line (window, style->black_gc, + x + width - 1, y, x + width - 1, y + height - 1); + */ + break; + + case GTK_SHADOW_ETCHED_IN: + case GTK_SHADOW_ETCHED_OUT: + thickness_light = 1; + thickness_dark = 1; + + for (i = 0; i < thickness_dark; i++) + { + gdk_draw_line (window, gc1, + x + i, + y + height - i - 1, + x + width - i - 1, + y + height - i - 1); + gdk_draw_line (window, gc1, + x + width - i - 1, + y + i, + x + width - i - 1, + y + height - i - 1); + + gdk_draw_line (window, gc2, + x + i, + y + i, + x + width - i - 2, + y + i); + gdk_draw_line (window, gc2, + x + i, + y + i, + x + i, + y + height - i - 2); + } + + for (i = 0; i < thickness_light; i++) + { + gdk_draw_line (window, gc1, + x + thickness_dark + i, + y + thickness_dark + i, + x + width - thickness_dark - i - 1, + y + thickness_dark + i); + gdk_draw_line (window, gc1, + x + thickness_dark + i, + y + thickness_dark + i, + x + thickness_dark + i, + y + height - thickness_dark - i - 1); + + gdk_draw_line (window, gc2, + x + thickness_dark + i, + y + height - thickness_light - i - 1, + x + width - thickness_light - 1, + y + height - thickness_light - i - 1); + gdk_draw_line (window, gc2, + x + width - thickness_light - i - 1, + y + thickness_dark + i, + x + width - thickness_light - i - 1, + y + height - thickness_light - 1); + } + break; + } + + if (area) + { + gdk_gc_set_clip_rectangle (gc1, NULL); + gdk_gc_set_clip_rectangle (gc2, NULL); + } +} + +void +draw_polygon (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GdkPoint *points, + gint npoints, + gint fill) +{ +#ifndef M_PI +# define M_PI 3.14159265358979323846 +#endif /* M_PI */ +#ifndef M_PI_4 +# define M_PI_4 0.78539816339744830962 +#endif /* M_PI_4 */ + + static const gdouble pi_over_4 = M_PI_4; + static const gdouble pi_3_over_4 = M_PI_4 * 3; + + GdkGC *gc1; + GdkGC *gc2; + GdkGC *gc3; + GdkGC *gc4; + gdouble angle; + gint xadjust; + gint yadjust; + gint i; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + g_return_if_fail (points != NULL); + + switch (shadow_type) + { + case GTK_SHADOW_IN: + gc1 = style->bg_gc[state_type]; + gc2 = style->dark_gc[state_type]; + gc3 = style->light_gc[state_type]; + gc4 = style->black_gc; + + gc1 = style->light_gc[state_type]; + gc2 = style->dark_gc[state_type]; + gc3 = style->light_gc[state_type]; + gc4 = style->dark_gc[state_type]; + break; + case GTK_SHADOW_OUT: + gc1 = style->dark_gc[state_type]; + gc2 = style->light_gc[state_type]; + gc3 = style->black_gc; + gc4 = style->bg_gc[state_type]; + + gc1 = style->dark_gc[state_type]; + gc2 = style->light_gc[state_type]; + gc3 = style->dark_gc[state_type]; + gc4 = style->light_gc[state_type]; + break; + default: + return; + } + + if (area) + { + gdk_gc_set_clip_rectangle (gc1, area); + gdk_gc_set_clip_rectangle (gc2, area); + gdk_gc_set_clip_rectangle (gc3, area); + gdk_gc_set_clip_rectangle (gc4, area); + } + if (fill) + gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints); + + npoints--; + + for (i = 0; i < npoints; i++) + { + if ((points[i].x == points[i+1].x) && + (points[i].y == points[i+1].y)) + { + angle = 0; + } + else + { + angle = atan2 (points[i+1].y - points[i].y, + points[i+1].x - points[i].x); + } + + if ((angle > -pi_3_over_4) && (angle < pi_over_4)) + { + if (angle > -pi_over_4) + { + xadjust = 0; + yadjust = 1; + } + else + { + xadjust = 1; + yadjust = 0; + } + + gdk_draw_line (window, gc1, + points[i].x-xadjust, points[i].y-yadjust, + points[i+1].x-xadjust, points[i+1].y-yadjust); + gdk_draw_line (window, gc3, + points[i].x, points[i].y, + points[i+1].x, points[i+1].y); + } + else + { + if ((angle < -pi_3_over_4) || (angle > pi_3_over_4)) + { + xadjust = 0; + yadjust = 1; + } + else + { + xadjust = 1; + yadjust = 0; + } + + gdk_draw_line (window, gc4, + points[i].x+xadjust, points[i].y+yadjust, + points[i+1].x+xadjust, points[i+1].y+yadjust); + gdk_draw_line (window, gc2, + points[i].x, points[i].y, + points[i+1].x, points[i+1].y); + } + } + if (area) + { + gdk_gc_set_clip_rectangle (gc1, NULL); + gdk_gc_set_clip_rectangle (gc2, NULL); + gdk_gc_set_clip_rectangle (gc3, NULL); + gdk_gc_set_clip_rectangle (gc4, NULL); + } +} + +void +draw_arrow (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GtkArrowType arrow_type, + gint fill, + gint x, + gint y, + gint width, + gint height) +{ + GdkGC *gc1; + GdkGC *gc2; + GdkGC *gc3; + GdkGC *gc4; + gint half_width; + gint half_height; + GdkPoint points[3]; + gchar setshape = 0; + GdkPixmap *pm = NULL; + GdkGC *pmgc = NULL; + GdkColor col; + gchar setbg = 0; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); +/* + switch (shadow_type) + { + case GTK_SHADOW_IN: + gc1 = style->bg_gc[state_type]; + gc2 = style->dark_gc[state_type]; + gc3 = style->light_gc[state_type]; + gc4 = style->black_gc; + + gc1 = style->light_gc[state_type]; + gc2 = style->black_gc; + gc3 = style->light_gc[state_type]; + gc4 = style->black_gc; + break; + case GTK_SHADOW_OUT: + gc1 = style->dark_gc[state_type]; + gc2 = style->light_gc[state_type]; + gc3 = style->black_gc; + gc4 = style->bg_gc[state_type]; + + gc1 = style->black_gc; + gc2 = style->light_gc[state_type]; + gc3 = style->black_gc; + gc4 = style->light_gc[state_type]; + break; + default: + return; + } +*/ + if ((width == -1) && (height == -1)) + { + gdk_window_get_size (window, &width, &height); + setshape = 1; + } + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + half_width = width / 2; + half_height = height / 2; + +/* + if (area) + { + gdk_gc_set_clip_rectangle (gc1, area); + gdk_gc_set_clip_rectangle (gc2, area); + gdk_gc_set_clip_rectangle (gc3, area); + gdk_gc_set_clip_rectangle (gc4, area); + } +*/ +/* if (setshape) + { + pm = gdk_pixmap_new (window, width, height, 1); + pmgc = gdk_gc_new (pm); + col.pixel = 0; + gdk_gc_set_foreground(pmgc, &col); + gdk_draw_rectangle(pm, pmgc, TRUE, 0, 0, width, height); + col.pixel = 1; + gdk_gc_set_foreground(pmgc, &col); + } +*/ + { + GdkImlibImage *im; + GdkImlibBorder bd; + + switch (arrow_type) + { + case GTK_ARROW_UP: + switch (shadow_type) + { + case GTK_SHADOW_NONE: + return; + break; + case GTK_SHADOW_IN: + case GTK_SHADOW_ETCHED_IN: + case GTK_SHADOW_OUT: + case GTK_SHADOW_ETCHED_OUT: + switch (state_type) + { + case GTK_STATE_NORMAL: + case GTK_STATE_INSENSITIVE: + im=load_image("_arrow_u1.png"); + break; + case GTK_STATE_PRELIGHT: + im=load_image("_arrow_u2.png"); + break; + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_arrow_u3.png"); + break; + } + break; + } + break; + case GTK_ARROW_DOWN: + switch (shadow_type) + { + case GTK_SHADOW_NONE: + return; + break; + case GTK_SHADOW_IN: + case GTK_SHADOW_ETCHED_IN: + case GTK_SHADOW_OUT: + case GTK_SHADOW_ETCHED_OUT: + switch (state_type) + { + case GTK_STATE_NORMAL: + case GTK_STATE_INSENSITIVE: + im=load_image("_arrow_d1.png"); + break; + case GTK_STATE_PRELIGHT: + im=load_image("_arrow_d2.png"); + break; + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_arrow_d3.png"); + break; + } + break; + } + break; + case GTK_ARROW_LEFT: + switch (shadow_type) + { + case GTK_SHADOW_NONE: + return; + break; + case GTK_SHADOW_IN: + case GTK_SHADOW_ETCHED_IN: + case GTK_SHADOW_OUT: + case GTK_SHADOW_ETCHED_OUT: + switch (state_type) + { + case GTK_STATE_NORMAL: + case GTK_STATE_INSENSITIVE: + im=load_image("_arrow_l1.png"); + break; + case GTK_STATE_PRELIGHT: + im=load_image("_arrow_l2.png"); + break; + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_arrow_l3.png"); + break; + } + break; + } + break; + case GTK_ARROW_RIGHT: + switch (shadow_type) + { + case GTK_SHADOW_NONE: + return; + break; + case GTK_SHADOW_IN: + case GTK_SHADOW_ETCHED_IN: + case GTK_SHADOW_OUT: + case GTK_SHADOW_ETCHED_OUT: + switch (state_type) + { + case GTK_STATE_NORMAL: + case GTK_STATE_INSENSITIVE: + im=load_image("_arrow_r1.png"); + break; + case GTK_STATE_PRELIGHT: + im=load_image("_arrow_r2.png"); + break; + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_arrow_r3.png"); + break; + } + break; + } + break; + } + if (im) + { + GdkPixmap *p, *m; + + bd.left=2; + bd.right=2; + bd.top=2; + bd.bottom=2; + gdk_imlib_set_image_border(im,&bd); + gdk_imlib_render(im,width,height); + + gc1 = style->bg_gc[state_type]; + + if (area) + gdk_gc_set_clip_rectangle (gc1, area); + + p = gdk_imlib_move_image(im); + m = gdk_imlib_move_mask(im); + if (p) + { + if (setbg) + { + gdk_window_set_back_pixmap(window, p, 0); + if (area) + gdk_window_clear_area(window, area->x, area->y, + area->width, area->height); + else + { + if (m) + gdk_window_shape_combine_mask(window, m, 0, 0); + gdk_window_clear(window); + } + } + else + { + if (m) + { + gdk_gc_set_clip_mask(gc1, m); + gdk_gc_set_clip_origin(gc1, x, y); + } + gdk_draw_pixmap(window, gc1, p, 0, 0, x, y, width, height); + if (m) + { + gdk_gc_set_clip_mask(gc1, NULL); + gdk_gc_set_clip_origin(gc1, 0, 0); + } + } + gdk_imlib_free_pixmap(p); + } + gdk_imlib_destroy_image(im); + + if (area) + gdk_gc_set_clip_rectangle (gc1, NULL); + } + else + { + gdk_window_clear_area(window,x,y,width,height); + } + } + return; + + switch (arrow_type) + { + case GTK_ARROW_UP: + if (fill) + { + points[0].x = x + half_width; + points[0].y = y; + points[1].x = x; + points[1].y = y + height - 1; + points[2].x = x + width - 1; + points[2].y = y + height - 1; + + gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3); + if (pm) + gdk_draw_polygon (pm, pmgc, TRUE, points, 3); + } + + gdk_draw_line (window, gc1, + x + 1, y + height - 2, + x + width - 2, y + height - 2); + gdk_draw_line (window, gc3, + x + 0, y + height - 1, + x + width - 1, y + height - 1); + + gdk_draw_line (window, gc1, + x + width - 2, y + height - 1, + x + half_width, y + 1); + gdk_draw_line (window, gc3, + x + width - 1, y + height - 1, + x + half_width, y); + + gdk_draw_line (window, gc4, + x + half_width, y + 1, + x + 1, y + height - 1); + gdk_draw_line (window, gc2, + x + half_width, y, + x, y + height - 1); + break; + case GTK_ARROW_DOWN: + if (fill) + { + points[0].x = x + width - 1; + points[0].y = y; + points[1].x = x; + points[1].y = y; + points[2].x = x + half_width; + points[2].y = y + height - 1; + + gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3); + if (pm) + gdk_draw_polygon (pm, pmgc, TRUE, points, 3); + } + + gdk_draw_line (window, gc4, + x + width - 2, + y + 1, x + 1, y + 1); + gdk_draw_line (window, gc2, + x + width - 1, y, + x, y); + + gdk_draw_line (window, gc4, + x + 1, y, + x + half_width, y + height - 2); + gdk_draw_line (window, gc2, + x, y, + x + half_width, y + height - 1); + + gdk_draw_line (window, gc1, + x + half_width, y + height - 2, + x + width - 2, y); + gdk_draw_line (window, gc3, + x + half_width, y + height - 1, + x + width - 1, y); + break; + case GTK_ARROW_LEFT: + if (fill) + { + points[0].x = x; + points[0].y = y + half_height; + points[1].x = x + width - 1; + points[1].y = y + height - 1; + points[2].x = x + width - 1; + points[2].y = y; + + gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3); + if (pm) + gdk_draw_polygon (pm, pmgc, TRUE, points, 3); + } + + gdk_draw_line (window, gc1, + x + 1, y + half_height, + x + width - 1, y + height - 1); + gdk_draw_line (window, gc3, + x, y + half_height, + x + width - 1, y + height - 1); + + gdk_draw_line (window, gc1, + x + width - 2, y + height - 1, + x + width - 2, y + 1); + gdk_draw_line (window, gc3, + x + width - 1, y + height - 1, + x + width - 1, y); + + gdk_draw_line (window, gc4, + x + width - 1, y + 1, + x + 1, y + half_height); + gdk_draw_line (window, gc2, + x + width - 1, y, + x, y + half_height); + break; + case GTK_ARROW_RIGHT: + if (fill) + { + points[0].x = x + width - 1; + points[0].y = y + half_height; + points[1].x = x; + points[1].y = y; + points[2].x = x; + points[2].y = y + height - 1; + + gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3); + if (pm) + gdk_draw_polygon (pm, pmgc, TRUE, points, 3); + } + + gdk_draw_line (window, gc4, + x + width - 1, y + half_height, + x + 1, y + 1); + gdk_draw_line (window, gc2, + x + width - 1, y + half_height, + x, y); + + gdk_draw_line (window, gc4, + x + 1, y + 1, + x + 1, y + height - 2); + gdk_draw_line (window, gc2, + x, y, + x, y + height - 1); + + gdk_draw_line (window, gc1, + x + 1, y + height - 2, + x + width - 1, y + half_height); + gdk_draw_line (window, gc3, + x, y + height - 1, + x + width - 1, y + half_height); + break; + } + if (setshape) + { + gdk_window_shape_combine_mask(window, pm, 0, 0); + gdk_pixmap_unref(pm); + gdk_gc_destroy(pmgc); + } + if (area) + { + gdk_gc_set_clip_rectangle (gc1, NULL); + gdk_gc_set_clip_rectangle (gc2, NULL); + gdk_gc_set_clip_rectangle (gc3, NULL); + gdk_gc_set_clip_rectangle (gc4, NULL); + } +} + +void +draw_diamond (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + gint half_width; + gint half_height; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if ((width == -1) && (height == -1)) + gdk_window_get_size (window, &width, &height); + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + half_width = width / 2; + half_height = height / 2; + + if (area) + { + gdk_gc_set_clip_rectangle (style->light_gc[state_type], area); + gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area); + gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area); + gdk_gc_set_clip_rectangle (style->black_gc, area); + } + switch (shadow_type) + { + case GTK_SHADOW_IN: + gdk_draw_line (window, style->light_gc[state_type], + x + 2, y + half_height, + x + half_width, y + height - 2); + gdk_draw_line (window, style->light_gc[state_type], + x + half_width, y + height - 2, + x + width - 2, y + half_height); + gdk_draw_line (window, style->light_gc[state_type], + x + 1, y + half_height, + x + half_width, y + height - 1); + gdk_draw_line (window, style->light_gc[state_type], + x + half_width, y + height - 1, + x + width - 1, y + half_height); + gdk_draw_line (window, style->light_gc[state_type], + x, y + half_height, + x + half_width, y + height); + gdk_draw_line (window, style->light_gc[state_type], + x + half_width, y + height, + x + width, y + half_height); + + gdk_draw_line (window, style->black_gc, + x + 2, y + half_height, + x + half_width, y + 2); + gdk_draw_line (window, style->black_gc, + x + half_width, y + 2, + x + width - 2, y + half_height); + gdk_draw_line (window, style->black_gc, + x + 1, y + half_height, + x + half_width, y + 1); + gdk_draw_line (window, style->black_gc, + x + half_width, y + 1, + x + width - 1, y + half_height); + gdk_draw_line (window, style->black_gc, + x, y + half_height, + x + half_width, y); + gdk_draw_line (window, style->black_gc, + x + half_width, y, + x + width, y + half_height); +/* + gdk_draw_line (window, style->bg_gc[state_type], + x + 2, y + half_height, + x + half_width, y + height - 2); + gdk_draw_line (window, style->bg_gc[state_type], + x + half_width, y + height - 2, + x + width - 2, y + half_height); + gdk_draw_line (window, style->light_gc[state_type], + x + 1, y + half_height, + x + half_width, y + height - 1); + gdk_draw_line (window, style->light_gc[state_type], + x + half_width, y + height - 1, + x + width - 1, y + half_height); + gdk_draw_line (window, style->light_gc[state_type], + x, y + half_height, + x + half_width, y + height); + gdk_draw_line (window, style->light_gc[state_type], + x + half_width, y + height, + x + width, y + half_height); + + gdk_draw_line (window, style->black_gc, + x + 2, y + half_height, + x + half_width, y + 2); + gdk_draw_line (window, style->black_gc, + x + half_width, y + 2, + x + width - 2, y + half_height); + gdk_draw_line (window, style->dark_gc[state_type], + x + 1, y + half_height, + x + half_width, y + 1); + gdk_draw_line (window, style->dark_gc[state_type], + x + half_width, y + 1, + x + width - 1, y + half_height); + gdk_draw_line (window, style->dark_gc[state_type], + x, y + half_height, + x + half_width, y); + gdk_draw_line (window, style->dark_gc[state_type], + x + half_width, y, + x + width, y + half_height); + */ + break; + case GTK_SHADOW_OUT: + gdk_draw_line (window, style->black_gc, + x + 2, y + half_height, + x + half_width, y + height - 2); + gdk_draw_line (window, style->black_gc, + x + half_width, y + height - 2, + x + width - 2, y + half_height); + gdk_draw_line (window, style->black_gc, + x + 1, y + half_height, + x + half_width, y + height - 1); + gdk_draw_line (window, style->black_gc, + x + half_width, y + height - 1, + x + width - 1, y + half_height); + gdk_draw_line (window, style->black_gc, + x, y + half_height, + x + half_width, y + height); + gdk_draw_line (window, style->black_gc, + x + half_width, y + height, + x + width, y + half_height); + + gdk_draw_line (window, style->light_gc[state_type], + x + 2, y + half_height, + x + half_width, y + 2); + gdk_draw_line (window, style->light_gc[state_type], + x + half_width, y + 2, + x + width - 2, y + half_height); + gdk_draw_line (window, style->light_gc[state_type], + x + 1, y + half_height, + x + half_width, y + 1); + gdk_draw_line (window, style->light_gc[state_type], + x + half_width, y + 1, + x + width - 1, y + half_height); + gdk_draw_line (window, style->light_gc[state_type], + x, y + half_height, + x + half_width, y); + gdk_draw_line (window, style->light_gc[state_type], + x + half_width, y, + x + width, y + half_height); +/* + gdk_draw_line (window, style->dark_gc[state_type], + x + 2, y + half_height, + x + half_width, y + height - 2); + gdk_draw_line (window, style->dark_gc[state_type], + x + half_width, y + height - 2, + x + width - 2, y + half_height); + gdk_draw_line (window, style->dark_gc[state_type], + x + 1, y + half_height, + x + half_width, y + height - 1); + gdk_draw_line (window, style->dark_gc[state_type], + x + half_width, y + height - 1, + x + width - 1, y + half_height); + gdk_draw_line (window, style->black_gc, + x, y + half_height, + x + half_width, y + height); + gdk_draw_line (window, style->black_gc, + x + half_width, y + height, + x + width, y + half_height); + + gdk_draw_line (window, style->bg_gc[state_type], + x + 2, y + half_height, + x + half_width, y + 2); + gdk_draw_line (window, style->bg_gc[state_type], + x + half_width, y + 2, + x + width - 2, y + half_height); + gdk_draw_line (window, style->light_gc[state_type], + x + 1, y + half_height, + x + half_width, y + 1); + gdk_draw_line (window, style->light_gc[state_type], + x + half_width, y + 1, + x + width - 1, y + half_height); + gdk_draw_line (window, style->light_gc[state_type], + x, y + half_height, + x + half_width, y); + gdk_draw_line (window, style->light_gc[state_type], + x + half_width, y, + x + width, y + half_height); +*/ + break; + default: + break; + } + if (area) + { + gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL); + gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL); + gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL); + gdk_gc_set_clip_rectangle (style->black_gc, NULL); + } +} + +void +draw_oval (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); +} + +void +draw_string (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + const gchar *string) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if (area) + { + gdk_gc_set_clip_rectangle (style->white_gc, area); + gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area); + } + if (state_type == GTK_STATE_INSENSITIVE) + gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string); + gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string); + if (area) + { + gdk_gc_set_clip_rectangle (style->white_gc, NULL); + gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL); + } +} + +void +draw_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + GdkGC *gc1; + GdkGC *gc2; + gchar setbg = 0; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if ((width == -1) && (height == -1)) + { + gdk_window_get_size (window, &width, &height); + setbg = 1; + } + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + { + GdkImlibImage *im; + GdkImlibBorder bd; + + if ((detail) && (!strcmp("hruler", detail))) + im=load_image("_ruleh.png"); + else if ((detail) && (!strcmp("vruler", detail))) + im=load_image("_rulev.png"); + else if ((detail) && (!strcmp("buttondefault", detail))) + im=load_image("_ruleh.png"); + else if ((detail) && (!strcmp("bar", detail))) + im=load_image("_prog_vgrad.png"); + else + { + switch (shadow_type) + { + case GTK_SHADOW_NONE: + switch (state_type) + { + case GTK_STATE_NORMAL: + case GTK_STATE_INSENSITIVE: + im=NULL; + break; + case GTK_STATE_PRELIGHT: + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=NULL; + break; + } + break; + case GTK_SHADOW_IN: + case GTK_SHADOW_ETCHED_IN: + switch (state_type) + { + case GTK_STATE_NORMAL: + im=load_image("_box_out_dgrad6.png"); + break; + case GTK_STATE_INSENSITIVE: + im=load_image("_box_out_dgrad5.png"); + break; + case GTK_STATE_PRELIGHT: + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_box_out_dgrad3.png"); + break; + } + break; + case GTK_SHADOW_OUT: + case GTK_SHADOW_ETCHED_OUT: + switch (state_type) + { + case GTK_STATE_NORMAL: + im=load_image("_box_out_dgrad1.png"); + break; + case GTK_STATE_INSENSITIVE: + im=load_image("_box_out_dgrad4.png"); + break; + case GTK_STATE_PRELIGHT: + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_box_out_dgrad2.png"); + break; + } + break; + } + } + if (im) + { + GdkPixmap *p, *m; + + bd.left=2; + bd.right=2; + bd.top=2; + bd.bottom=2; + gdk_imlib_set_image_border(im,&bd); + gdk_imlib_render(im,width,height); + + gc1 = style->bg_gc[state_type]; + + if (area) + gdk_gc_set_clip_rectangle (gc1, area); + + p = gdk_imlib_move_image(im); + m = gdk_imlib_move_mask(im); + if (p) + { + if (setbg) + { + gdk_window_set_back_pixmap(window, p, 0); + if (area) + gdk_window_clear_area(window, area->x, area->y, + area->width, area->height); + else + { + if (m) + gdk_window_shape_combine_mask(window, m, 0, 0); + gdk_window_clear(window); + } + } + else + { + if (m) + { + gdk_gc_set_clip_mask(gc1, m); + gdk_gc_set_clip_origin(gc1, x, y); + } + gdk_draw_pixmap(window, gc1, p, 0, 0, x, y, width, height); + if (m) + { + gdk_gc_set_clip_mask(gc1, NULL); + gdk_gc_set_clip_origin(gc1, 0, 0); + } + } + gdk_imlib_free_pixmap(p); + } + gdk_imlib_destroy_image(im); + + if (area) + gdk_gc_set_clip_rectangle (gc1, NULL); + } + else + { + gdk_window_clear_area(window,x,y,width,height); + } + } + return; + + switch (shadow_type) + { + case GTK_SHADOW_NONE: + gc1 = NULL; + gc2 = NULL; + break; + case GTK_SHADOW_IN: + case GTK_SHADOW_ETCHED_IN: + gc1 = style->light_gc[state_type]; + gc2 = style->dark_gc[state_type]; + break; + case GTK_SHADOW_OUT: + case GTK_SHADOW_ETCHED_OUT: + gc1 = style->dark_gc[state_type]; + gc2 = style->light_gc[state_type]; + break; + } + + if (area) + { + gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area); + } + gdk_draw_rectangle(window, style->bg_gc[state_type], TRUE, + x, y, width, height); + if (area) + { + gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL); + } + draw_shadow (style, window, state_type, shadow_type, area, widget, detail, + x, y, width, height); +} + +void +draw_flat_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + GdkGC *gc1; + gchar setbg = 0; + GdkRectangle rect, new_area; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if ((width == -1) && (height == -1)) + { + gdk_window_get_size (window, &width, &height); + setbg = 1; + } + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + if (area) + { + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + gdk_rectangle_intersect(area, &rect, &new_area); + } + { + GdkImlibImage *im; + GdkImlibBorder bd; + +/* + if ((detail) && ((!strcmp(detail, "listitem")) || (!strcmp(detail, "treeitem")))) + { + gtk_style_set_background (style, window, state_type); + gdk_window_clear_area(window,x,y,width,height); + return; + } + */ +/* + if (area) + gdk_draw_rectangle(window, style->bg_gc[state_type], TRUE, + new_area.x, new_area.y, + new_area.width, new_area.height); + else + gdk_draw_rectangle(window, style->bg_gc[state_type], TRUE, + x, y, width, height); + */ + switch (shadow_type) + { + case GTK_SHADOW_NONE: + switch (state_type) + { + case GTK_STATE_NORMAL: + case GTK_STATE_INSENSITIVE: + if ((detail) && (!strcmp("selected",detail))) + im=load_image("_box_out_dgrad6.png"); + else if ((detail) && (!strcmp("viewportbin",detail))) + im=load_image("_box_out_dgrad5.png"); + else if ((detail) && (!strcmp("curve_bg",detail))) + im=load_image("_box_out_dgrad3.png"); + else + im=load_image("_box_out_dgrad1.png"); + break; + case GTK_STATE_PRELIGHT: + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_box_out_dgrad1.png"); + break; + } + break; + case GTK_SHADOW_IN: + case GTK_SHADOW_ETCHED_IN: + switch (state_type) + { + case GTK_STATE_NORMAL: + case GTK_STATE_INSENSITIVE: + im=load_image("_box_out_dgrad1.png"); + break; + case GTK_STATE_PRELIGHT: + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_box_out_dgrad1.png"); + break; + } + break; + case GTK_SHADOW_OUT: + case GTK_SHADOW_ETCHED_OUT: + switch (state_type) + { + case GTK_STATE_NORMAL: + case GTK_STATE_INSENSITIVE: + if ((detail) && (!strcmp("tooltip",detail))) + im=load_image("_ruleh.png"); + else + im=load_image("_box_out_dgrad1.png"); + break; + case GTK_STATE_PRELIGHT: + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_box_out_dgrad1.png"); + break; + } + break; + } + if (im) + { + GdkPixmap *p, *m; + + bd.left=2; + bd.right=2; + bd.top=2; + bd.bottom=2; + gdk_imlib_set_image_border(im,&bd); + gdk_imlib_render(im,width,height); + + gc1 = style->bg_gc[state_type]; + + if (area) + gdk_gc_set_clip_rectangle (gc1, area); + + p = gdk_imlib_move_image(im); + m = gdk_imlib_move_mask(im); + if (p) + { + if (setbg) + { + gdk_window_set_back_pixmap(window, p, 0); + if (area) + gdk_window_clear_area(window, area->x, area->y, + area->width, area->height); + else + { + if (m) + gdk_window_shape_combine_mask(window, m, 0, 0); + gdk_window_clear(window); + } + } + else + { + if (m) + { + gdk_gc_set_clip_mask(gc1, m); + gdk_gc_set_clip_origin(gc1, x, y); + } + gdk_draw_pixmap(window, gc1, p, 0, 0, x, y, width, height); + if (m) + { + gdk_gc_set_clip_mask(gc1, NULL); + gdk_gc_set_clip_origin(gc1, 0, 0); + } + } + gdk_imlib_free_pixmap(p); + } + gdk_imlib_destroy_image(im); + + if (area) + gdk_gc_set_clip_rectangle (gc1, NULL); + } + else + { + gdk_window_clear_area(window,x,y,width,height); + } + } +} + +void +draw_check (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + GdkGC *gc1; + GdkGC *gc2; + gint thickness_light; + gint thickness_dark; + gint i; + gchar setbg = 0; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + +/* + draw_box (style, window, state_type, shadow_type, area, widget, detail, + x, y, width, height);*/ + + if ((width == -1) && (height == -1)) + { + gdk_window_get_size (window, &width, &height); + setbg = 1; + } + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + if ((width > 0) && (height > 0)) + { + GdkImlibImage *im; + GdkImlibBorder bd; + + switch (shadow_type) + { + case GTK_SHADOW_NONE: + switch (state_type) + { + case GTK_STATE_NORMAL: + case GTK_STATE_INSENSITIVE: + im=load_image("_check1.png"); + break; + case GTK_STATE_PRELIGHT: + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_check1.png"); + break; + } + break; + case GTK_SHADOW_IN: + case GTK_SHADOW_ETCHED_IN: + switch (state_type) + { + case GTK_STATE_NORMAL: + case GTK_STATE_INSENSITIVE: + im=load_image("_check2.png"); + break; + case GTK_STATE_PRELIGHT: + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_check2.png"); + break; + } + break; + case GTK_SHADOW_OUT: + case GTK_SHADOW_ETCHED_OUT: + switch (state_type) + { + case GTK_STATE_NORMAL: + case GTK_STATE_INSENSITIVE: + im=load_image("_check1.png"); + break; + case GTK_STATE_PRELIGHT: + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_check1.png"); + break; + } + break; + } + if (im) + { + GdkPixmap *p, *m; + + gdk_imlib_render(im,width,height); + + gc1 = style->black_gc; + + if (area) + gdk_gc_set_clip_rectangle (gc1, area); + + p = gdk_imlib_move_image(im); + m = gdk_imlib_move_mask(im); + if (p) + { + if (m) + { + gdk_gc_set_clip_mask(gc1, m); + gdk_gc_set_clip_origin(gc1, x, y); + } + gdk_draw_pixmap(window, gc1, p, 0, 0, x, y, width, height); + if (m) + { + gdk_gc_set_clip_mask(gc1, NULL); + gdk_gc_set_clip_origin(gc1, 0, 0); + } + gdk_imlib_free_pixmap(p); + } + gdk_imlib_destroy_image(im); + + if (area) + gdk_gc_set_clip_rectangle (gc1, NULL); + } + } +} + +void +draw_option (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + GdkGC *gc1; + GdkGC *gc2; + gint thickness_light; + gint thickness_dark; + gint i; + gchar setbg = 0; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + +/* + draw_diamond(style, window, state_type, shadow_type, area, widget, + detail, x, y, width, height);*/ + + if ((width == -1) && (height == -1)) + { + gdk_window_get_size (window, &width, &height); + setbg = 1; + } + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + { + GdkImlibImage *im; + GdkImlibBorder bd; + + switch (shadow_type) + { + case GTK_SHADOW_NONE: + switch (state_type) + { + case GTK_STATE_NORMAL: + case GTK_STATE_INSENSITIVE: + im=NULL; + break; + case GTK_STATE_PRELIGHT: + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=NULL; + break; + } + break; + case GTK_SHADOW_IN: + case GTK_SHADOW_ETCHED_IN: + switch (state_type) + { + case GTK_STATE_NORMAL: + case GTK_STATE_INSENSITIVE: + im=load_image("_option2.png"); + break; + case GTK_STATE_PRELIGHT: + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_option2.png"); + break; + } + break; + case GTK_SHADOW_OUT: + case GTK_SHADOW_ETCHED_OUT: + switch (state_type) + { + case GTK_STATE_NORMAL: + case GTK_STATE_INSENSITIVE: + im=load_image("_option1.png"); + break; + case GTK_STATE_PRELIGHT: + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_option1.png"); + break; + } + break; + } + if (im) + { + GdkPixmap *p, *m; + + gdk_imlib_render(im,width,height); + + gc1 = style->black_gc; + + if (area) + gdk_gc_set_clip_rectangle (gc1, area); + + p = gdk_imlib_move_image(im); + m = gdk_imlib_move_mask(im); + if (p) + { + if (setbg) + { + gdk_window_set_back_pixmap(window, p, 0); + if (area) + gdk_window_clear_area(window, area->x, area->y, + area->width, area->height); + else + { + if (m) + gdk_window_shape_combine_mask(window, m, 0, 0); + gdk_window_clear(window); + } + } + else + { + if (m) + { + gdk_gc_set_clip_mask(gc1, m); + gdk_gc_set_clip_origin(gc1, x, y); + } + gdk_draw_pixmap(window, gc1, p, 0, 0, x, y, width, height); + if (m) + { + gdk_gc_set_clip_mask(gc1, NULL); + gdk_gc_set_clip_origin(gc1, 0, 0); + } + } + gdk_imlib_free_pixmap(p); + } + gdk_imlib_destroy_image(im); + + if (area) + gdk_gc_set_clip_rectangle (gc1, NULL); + } + } +} + +void +draw_cross (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); +} + +void +draw_ramp (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GtkArrowType arrow_type, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); +} + +void +draw_tab (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + draw_box (style, window, state_type, shadow_type, area, widget, detail, + x, y, width, height); +} + +void +draw_shadow_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + gint gap_side, + gint gap_x, + gint gap_width) +{ + GdkRectangle rect, new_area; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); + + if (gap_side == 0) + /* top */ + { + rect.x = x + gap_x; + rect.y = y; + rect.width = gap_width; + rect.height = 2; + } + else if (gap_side == 1) + /* bottom */ + { + rect.x = x+ gap_x; + rect.y = y + height - 2; + rect.width = gap_width; + rect.height = 2; + } + else if (gap_side == 2) + /* left */ + { + rect.x = x; + rect.y = y + gap_x; + rect.width = 2; + rect.height = gap_width; + } + else if (gap_side == 3) + /* right */ + { + rect.x = x + width - 2; + rect.y = y + gap_x; + rect.width = 2; + rect.height = gap_width; + } + + if (area) + { + if (gdk_rectangle_intersect(area, &rect, &new_area)) + { + gdk_window_clear_area(window, new_area.x, new_area.y, + new_area.width, new_area.height); + } + } + else + { + new_area.x = rect.x; + new_area.y = rect.y; + new_area.width = rect.width; + new_area.height = rect.height; + gdk_window_clear_area(window, new_area.x, new_area.y, + new_area.width, new_area.height); + } +} + +void +draw_box_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + gint gap_side, + gint gap_x, + gint gap_width) +{ + GdkGC *gc1; + GdkGC *gc2; + gint thickness_light; + gint thickness_dark; + gint i; + gchar setbg = 0; + GdkRectangle rect, new_area; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if ((width == -1) && (height == -1)) + { + gdk_window_get_size (window, &width, &height); + setbg = 1; + } + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + if (gap_side == 0) + /* top */ + { + rect.x = x + gap_x; + rect.y = y; + rect.width = gap_width; + rect.height = 2; + } + else if (gap_side == 1) + /* bottom */ + { + rect.x = x+ gap_x; + rect.y = y + height - 2; + rect.width = gap_width; + rect.height = 2; + } + else if (gap_side == 2) + /* left */ + { + rect.x = x; + rect.y = y + gap_x; + rect.width = 2; + rect.height = gap_width; + } + else if (gap_side == 3) + /* right */ + { + rect.x = x + width - 2; + rect.y = y + gap_x; + rect.width = 2; + rect.height = gap_width; + } + + { + GdkImlibImage *im; + GdkImlibBorder bd; + + if ((detail) && (!strcmp("hruler", detail))) + im=load_image("_ruleh.png"); + else if ((detail) && (!strcmp("vruler", detail))) + im=load_image("_rulev.png"); + else if ((detail) && (!strcmp("buttondefault", detail))) + im=load_image("_ruleh.png"); + else if ((detail) && (!strcmp("bar", detail))) + im=load_image("_prog_vgrad.png"); + else + { + switch (shadow_type) + { + case GTK_SHADOW_NONE: + switch (state_type) + { + case GTK_STATE_NORMAL: + case GTK_STATE_INSENSITIVE: + im=NULL; + break; + case GTK_STATE_PRELIGHT: + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=NULL; + break; + } + break; + case GTK_SHADOW_IN: + case GTK_SHADOW_ETCHED_IN: + switch (state_type) + { + case GTK_STATE_NORMAL: + im=load_image("_box_out_dgrad6.png"); + break; + case GTK_STATE_INSENSITIVE: + im=load_image("_box_out_dgrad5.png"); + break; + case GTK_STATE_PRELIGHT: + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_box_out_dgrad3.png"); + break; + } + break; + case GTK_SHADOW_OUT: + case GTK_SHADOW_ETCHED_OUT: + switch (state_type) + { + case GTK_STATE_NORMAL: + im=load_image("_box_out_dgrad1.png"); + break; + case GTK_STATE_INSENSITIVE: + im=load_image("_box_out_dgrad4.png"); + break; + case GTK_STATE_PRELIGHT: + case GTK_STATE_ACTIVE: + case GTK_STATE_SELECTED: + im=load_image("_box_out_dgrad2.png"); + break; + } + break; + } + } + if (im) + { + GdkPixmap *p, *m; + + bd.left=2; + bd.right=2; + bd.top=2; + bd.bottom=2; + gdk_imlib_set_image_border(im,&bd); + gdk_imlib_render(im,width,height); + + gc1 = style->bg_gc[state_type]; + + if (area) + gdk_gc_set_clip_rectangle (gc1, area); + + p = gdk_imlib_move_image(im); + m = gdk_imlib_move_mask(im); + if (p) + { + if (setbg) + { + gdk_window_set_back_pixmap(window, p, 0); + if (area) + gdk_window_clear_area(window, area->x, area->y, + area->width, area->height); + else + { + if (m) + gdk_window_shape_combine_mask(window, m, 0, 0); + gdk_window_clear(window); + } + } + else + { + if (m) + { + gdk_gc_set_clip_mask(gc1, m); + gdk_gc_set_clip_origin(gc1, x, y); + } + gdk_draw_pixmap(window, gc1, p, 0, 0, x, y, width, height); + if (m) + { + gdk_gc_set_clip_mask(gc1, NULL); + gdk_gc_set_clip_origin(gc1, 0, 0); + } + } + gdk_imlib_free_pixmap(p); + } + gdk_imlib_destroy_image(im); + + if (area) + gdk_gc_set_clip_rectangle (gc1, NULL); + } + else + { + gdk_window_clear_area(window,x,y,width,height); + } + } + if (area) + { + if (gdk_rectangle_intersect(area, &rect, &new_area)) + { + gdk_window_clear_area(window, new_area.x, new_area.y, + new_area.width, new_area.height); + } + } + else + { + new_area.x = rect.x; + new_area.y = rect.y; + new_area.width = rect.width; + new_area.height = rect.height; + gdk_window_clear_area(window, new_area.x, new_area.y, + new_area.width, new_area.height); + } + return; + + switch (shadow_type) + { + case GTK_SHADOW_NONE: + gc1 = NULL; + gc2 = NULL; + break; + case GTK_SHADOW_IN: + case GTK_SHADOW_ETCHED_IN: + gc1 = style->light_gc[state_type]; + gc2 = style->dark_gc[state_type]; + break; + case GTK_SHADOW_OUT: + case GTK_SHADOW_ETCHED_OUT: + gc1 = style->dark_gc[state_type]; + gc2 = style->light_gc[state_type]; + break; + } + + gdk_draw_rectangle(window, style->bg_gc[state_type], TRUE, + x, y, width, height); + + switch (shadow_type) + { + case GTK_SHADOW_NONE: + break; + + case GTK_SHADOW_IN: + gdk_draw_line (window, gc1, + x, y + height - 1, x + width - 1, y + height - 1); + gdk_draw_line (window, gc1, + x + width - 1, y, x + width - 1, y + height - 1); + + gdk_draw_line (window, gc1, + x + 1, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, gc1, + x + width - 2, y + 1, x + width - 2, y + height - 2); +/* + gdk_draw_line (window, style->bg_gc[state_type], + x + 1, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, style->bg_gc[state_type], + x + width - 2, y + 1, x + width - 2, y + height - 2); +*/ + gdk_draw_line (window, gc2, + x + 1, y + 1, x + width - 2, y + 1); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + 1, y + height - 2); +/* + gdk_draw_line (window, style->black_gc, + x + 1, y + 1, x + width - 2, y + 1); + gdk_draw_line (window, style->black_gc, + x + 1, y + 1, x + 1, y + height - 2); +*/ + gdk_draw_line (window, gc2, + x, y, x + width - 1, y); + gdk_draw_line (window, gc2, + x, y, x, y + height - 1); + break; + + case GTK_SHADOW_OUT: + gdk_draw_line (window, gc1, + x + 1, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, gc1, + x + width - 2, y + 1, x + width - 2, y + height - 2); + + gdk_draw_line (window, gc2, + x, y, x + width - 1, y); + gdk_draw_line (window, gc2, + x, y, x, y + height - 1); + + gdk_draw_line (window, gc2, + x + 1, y + 1, x + width - 2, y + 1); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + 1, y + height - 2); + + gdk_draw_line (window, gc1, + x, y + height - 1, x + width - 1, y + height - 1); + gdk_draw_line (window, gc1, + x + width - 1, y, x + width - 1, y + height - 1); +/* + gdk_draw_line (window, style->bg_gc[state_type], + x + 1, y + 1, x + width - 2, y + 1); + gdk_draw_line (window, style->bg_gc[state_type], + x + 1, y + 1, x + 1, y + height - 2); + + gdk_draw_line (window, style->black_gc, + x, y + height - 1, x + width - 1, y + height - 1); + gdk_draw_line (window, style->black_gc, + x + width - 1, y, x + width - 1, y + height - 1); + */ + break; + + case GTK_SHADOW_ETCHED_IN: + case GTK_SHADOW_ETCHED_OUT: + thickness_light = 1; + thickness_dark = 1; + + for (i = 0; i < thickness_dark; i++) + { + gdk_draw_line (window, gc1, + x + i, + y + height - i - 1, + x + width - i - 1, + y + height - i - 1); + gdk_draw_line (window, gc1, + x + width - i - 1, + y + i, + x + width - i - 1, + y + height - i - 1); + + gdk_draw_line (window, gc2, + x + i, + y + i, + x + width - i - 2, + y + i); + gdk_draw_line (window, gc2, + x + i, + y + i, + x + i, + y + height - i - 2); + } + + for (i = 0; i < thickness_light; i++) + { + gdk_draw_line (window, gc1, + x + thickness_dark + i, + y + thickness_dark + i, + x + width - thickness_dark - i - 1, + y + thickness_dark + i); + gdk_draw_line (window, gc1, + x + thickness_dark + i, + y + thickness_dark + i, + x + thickness_dark + i, + y + height - thickness_dark - i - 1); + + gdk_draw_line (window, gc2, + x + thickness_dark + i, + y + height - thickness_light - i - 1, + x + width - thickness_light - 1, + y + height - thickness_light - i - 1); + gdk_draw_line (window, gc2, + x + width - thickness_light - i - 1, + y + thickness_dark + i, + x + width - thickness_light - i - 1, + y + height - thickness_light - 1); + } + break; + } +} + +void +draw_extension (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + gint gap_side) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + draw_box(style, window, state_type, shadow_type, area, widget, detail, + x, y, width, height); +} + + +void +draw_focus (GtkStyle *style, + GdkWindow *window, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + GdkGC *gc1; + GdkGC *gc2; + gint thickness_light; + gint thickness_dark; + gint i; + gchar setbg = 0; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if ((width == -1) && (height == -1)) + { + gdk_window_get_size (window, &width, &height); + width -= 1; + height -= 1; + } + else if (width == -1) + { + gdk_window_get_size (window, &width, NULL); + width -= 1; + } + else if (height == -1) + { + gdk_window_get_size (window, NULL, &height); + height -= 1; + } + width++; + height++; + + if ((width > 0) && (height > 0)) + { + GdkImlibImage *im; + GdkImlibBorder bd; + + im=load_image("_focus.png"); + if (im) + { + GdkPixmap *p, *m; + + bd.left=1; + bd.right=1; + bd.top=1; + bd.bottom=1; + gdk_imlib_set_image_border(im,&bd); + gdk_imlib_render(im,width,height); + + gc1 = style->black_gc; + + if (area) + gdk_gc_set_clip_rectangle (gc1, area); + + p = gdk_imlib_move_image(im); + m = gdk_imlib_move_mask(im); + if (p) + { + if (setbg) + { + gdk_window_set_back_pixmap(window, p, 0); + if (area) + gdk_window_clear_area(window, area->x, area->y, + area->width, area->height); + else + { + if (m) + gdk_window_shape_combine_mask(window, m, 0, 0); + gdk_window_clear(window); + } + } + else + { + if (m) + { + gdk_gc_set_clip_mask(gc1, m); + gdk_gc_set_clip_origin(gc1, x, y); + } + gdk_draw_pixmap(window, gc1, p, 0, 0, x, y, width, height); + if (m) + { + gdk_gc_set_clip_mask(gc1, NULL); + gdk_gc_set_clip_origin(gc1, 0, 0); + } + } + gdk_imlib_free_pixmap(p); + } + gdk_imlib_destroy_image(im); + + if (area) + gdk_gc_set_clip_rectangle (gc1, NULL); + } + } +/* + gdk_draw_rectangle (window, + style->black_gc, FALSE, + x, y, width, height); + */ +} + +void +draw_slider (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if ((width == -1) && (height == -1)) + gdk_window_get_size (window, &width, &height); + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + gtk_draw_box (style, window, state_type, shadow_type, x, y, + width, height); + if (orientation == GTK_ORIENTATION_HORIZONTAL) + draw_vline (style, window, state_type, area, widget, detail, + style->klass->ythickness, + height - style->klass->ythickness - 1, width / 2); + else + draw_hline (style, window, state_type, area, widget, detail, + style->klass->xthickness, + width - style->klass->xthickness - 1, height / 2); +} + +void +draw_entry (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if ((width == -1) && (height == -1)) + gdk_window_get_size (window, &width, &height); + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + if (area) + gdk_gc_set_clip_rectangle (style->base_gc[state_type], area); + if (!strcmp("selected",detail)) + { + if (state_type == GTK_STATE_ACTIVE) + draw_flat_box(style, window, GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, + area, widget, detail, + x, y, width, height); + else + draw_flat_box(style, window, state_type, GTK_SHADOW_NONE, + area, widget, detail, + x, y, width, height); + /* + gdk_draw_rectangle (window, + style->bg_gc[state_type], + TRUE, + x, y, + width, + height);*/ + } + else + { + if (area) + gdk_gc_set_clip_rectangle (style->base_gc[state_type], area); + gdk_draw_rectangle (window, + style->base_gc[state_type], + TRUE, + x, y, + width, + height); + if (area) + gdk_gc_set_clip_rectangle (style->base_gc[state_type], NULL); + } +} + +void +draw_handle (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation) +{ + int xx, yy; + int xthick, ythick; + GdkGC *light_gc, *dark_gc; + GdkRectangle dest; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if ((width == -1) && (height == -1)) + gdk_window_get_size (window, &width, &height); + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + draw_box (style, window, state_type, shadow_type, area, widget, detail, + x, y, width, height); + + light_gc = style->light_gc[state_type]; + dark_gc = style->dark_gc[state_type]; + + xthick = style->klass->xthickness; + ythick = style->klass->ythickness; + + dest.x = x + xthick; + dest.y = y + ythick; + dest.width = width - (xthick * 2); + dest.height = height - (ythick * 2); + + gdk_gc_set_clip_rectangle (light_gc, &dest); + gdk_gc_set_clip_rectangle (dark_gc, &dest); + + for (yy = y + ythick; yy < (y + height - ythick); yy += 3) + for (xx = x + xthick; xx < (x + width - xthick); xx += 6) + { + gdk_draw_point (window, light_gc, xx, yy); + gdk_draw_point (window, dark_gc, xx + 1, yy + 1); + + gdk_draw_point (window, light_gc, xx + 3, yy + 1); + gdk_draw_point (window, dark_gc, xx + 4, yy + 2); + } + gdk_gc_set_clip_rectangle (light_gc, NULL); + gdk_gc_set_clip_rectangle (dark_gc, NULL); +} diff --git a/themes/pixmap_theme_main.c b/themes/pixmap_theme_main.c new file mode 100644 index 0000000000..687e29271e --- /dev/null +++ b/themes/pixmap_theme_main.c @@ -0,0 +1,611 @@ +#include "pixmap_theme.h" +/* Theme functions to export */ +void theme_init (GtkThemeEngine *engine); +void theme_exit (void); + +/* Exported vtable from th_draw */ + +extern GtkStyleClass th_default_class; + +/* internals */ + +/* external theme functions called */ + +typedef struct { + gchar *name; +} ThemeRcData; + +typedef struct { + gchar *name; +} ThemeStyleData; + +enum { + TOKEN_IMAGE = G_TOKEN_LAST + 1, + TOKEN_FUNCTION, + TOKEN_FILE, + TOKEN_RECOLORABLE, + TOKEN_BORDER, + TOKEN_DETAIL, + TOKEN_STATE, + TOKEN_SHADOW, + TOKEN_D_HLINE, + TOKEN_D_VLINE, + TOKEN_D_SHADOW, + TOKEN_D_POLYGON, + TOKEN_D_ARROW, + TOKEN_D_DIAMOND, + TOKEN_D_OVAL, + TOKEN_D_STRING, + TOKEN_D_BOX, + TOKEN_D_FLAT_BOX, + TOKEN_D_CHECK, + TOKEN_D_OPTION, + TOKEN_D_CROSS, + TOKEN_D_RAMP, + TOKEN_D_TAB, + TOKEN_D_SHADOW_GAP, + TOKEN_D_BOX_GAP, + TOKEN_D_EXTENSION, + TOKEN_D_FOCUS, + TOKEN_D_SLIDER, + TOKEN_D_ENTRY, + TOKEN_D_HANDLE, + TOKEN_TRUE, + TOKEN_FALSE, + TOKEN_TOP, + TOKEN_UP, + TOKEN_BOTTOM, + TOKEN_DOWN, + TOKEN_LEFT, + TOKEN_RIGHT, +}; + +static struct +{ + gchar *name; + guint token; +} theme_symbols[] = { + { "image", TOKEN_IMAGE }, + { "function", TOKEN_FUNCTION }, + { "file", TOKEN_FILE }, + { "recolorable", TOKEN_RECOLORABLE }, + { "border", TOKEN_BORDER }, + { "detail", TOKEN_DETAIL }, + { "state", TOKEN_STATE }, + { "shadow", TOKEN_SHADOW }, + + { "HILNE", TOKEN_D_HLINE }, + { "VLINE", TOKEN_D_VLINE }, + { "SHADOW", TOKEN_D_SHADOW }, + { "POLYGON", TOKEN_D_POLYGON }, + { "ARROW", TOKEN_D_ARROW }, + { "DIAMOND", TOKEN_D_DIAMOND }, + { "OVAL", TOKEN_D_OVAL }, + { "STRING", TOKEN_D_STRING }, + { "BOX", TOKEN_D_BOX }, + { "FLAT_BOX", TOKEN_D_FLAT_BOX }, + { "CHECK", TOKEN_D_CHECK }, + { "OPTION", TOKEN_D_OPTION }, + { "CROSS", TOKEN_D_CROSS }, + { "RAMP", TOKEN_D_RAMP }, + { "TAB", TOKEN_D_TAB }, + { "SHADOW_GAP", TOKEN_D_SHADOW_GAP }, + { "BOX_GAP", TOKEN_D_BOX_GAP }, + { "EXTENSION", TOKEN_D_EXTENSION }, + { "FOCUS", TOKEN_D_FOCUS }, + { "SLIDER", TOKEN_D_SLIDER }, + { "ENTRY", TOKEN_D_ENTRY }, + { "HANDLE", TOKEN_D_HANDLE }, + + { "TRUE", TOKEN_TRUE }, + { "FALSE", TOKEN_FALSE }, + + { "TOP", TOKEN_TOP }, + { "UP", TOKEN_UP }, + { "BOTTOM", TOKEN_BOTTOM }, + { "DOWN", TOKEN_DOWN }, + { "LEFT", TOKEN_LEFT }, + { "RIGHT", TOKEN_RIGHT }, +}; + +static guint n_theme_symbols = sizeof (theme_symbols) / sizeof (theme_symbols[0]); + +struct theme_image +{ + guint function; + gchar *file; + gchar recolorable; + GdkImlibBorder border; + gchar *detail; + GtkStateType state; + GtkShadowType shadow; +}; + +guint +theme_parse_function (GScanner *scanner, + struct theme_image *data) +{ + guint token; + + token = g_scanner_get_next_token (scanner); + if (token != TOKEN_FUNCTION) + return TOKEN_FUNCTION; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_EQUAL_SIGN) + return G_TOKEN_EQUAL_SIGN; + + token = g_scanner_get_next_token (scanner); + + return G_TOKEN_NONE; +} + +guint +theme_parse_file (GScanner *scanner, + struct theme_image *data) +{ + guint token; + + token = g_scanner_get_next_token (scanner); + if (token != TOKEN_FILE) + return TOKEN_FILE; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_EQUAL_SIGN) + return G_TOKEN_EQUAL_SIGN; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_STRING) + return G_TOKEN_STRING; + data->file = g_strdup (scanner->value.v_string); + + return G_TOKEN_NONE; +} + +guint +theme_parse_recolorable (GScanner *scanner, + struct theme_image *data) +{ + guint token; + + token = g_scanner_get_next_token (scanner); + if (token != TOKEN_RECOLORABLE) + return TOKEN_RECOLORABLE; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_EQUAL_SIGN) + return G_TOKEN_EQUAL_SIGN; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_STRING) + return G_TOKEN_STRING; + + data->file = g_strdup (scanner->value.v_string); + + return G_TOKEN_NONE; +} + +guint +theme_parse_border (GScanner *scanner, + GdkImlibBorder *border) +{ + guint token; + + token = g_scanner_get_next_token (scanner); + if (token != TOKEN_BORDER) + return TOKEN_BORDER; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_EQUAL_SIGN) + return G_TOKEN_EQUAL_SIGN; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_LEFT_CURLY) + return G_TOKEN_LEFT_CURLY; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_INT) + return G_TOKEN_INT; + border->left = scanner->value.v_int; + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_COMMA) + return G_TOKEN_COMMA; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_INT) + return G_TOKEN_INT; + border->right = scanner->value.v_int; + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_COMMA) + return G_TOKEN_COMMA; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_INT) + return G_TOKEN_INT; + border->top = scanner->value.v_int; + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_COMMA) + return G_TOKEN_COMMA; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_INT) + return G_TOKEN_INT; + border->bottom = scanner->value.v_int; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_RIGHT_CURLY) + return G_TOKEN_RIGHT_CURLY; + + return G_TOKEN_NONE; +} + +guint +theme_parse_detail (GScanner *scanner, + struct theme_image *data) +{ + guint token; + + token = g_scanner_get_next_token (scanner); + if (token != TOKEN_DETAIL) + return TOKEN_DETAIL; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_EQUAL_SIGN) + return G_TOKEN_EQUAL_SIGN; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_STRING) + return G_TOKEN_STRING; + + data->file = g_strdup (scanner->value.v_string); + + return G_TOKEN_NONE; +} + +guint +theme_parse_state (GScanner *scanner, + struct theme_image *data) +{ + guint token; + + token = g_scanner_get_next_token (scanner); + if (token != TOKEN_STATE) + return TOKEN_STATE; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_EQUAL_SIGN) + return G_TOKEN_EQUAL_SIGN; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_STRING) + return G_TOKEN_STRING; + + data->file = g_strdup (scanner->value.v_string); + + return G_TOKEN_NONE; +} + +guint +theme_parse_shadow (GScanner *scanner, + struct theme_image *data) +{ + guint token; + + token = g_scanner_get_next_token (scanner); + if (token != TOKEN_SHADOW) + return TOKEN_SHADOW; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_EQUAL_SIGN) + return G_TOKEN_EQUAL_SIGN; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_STRING) + return G_TOKEN_STRING; + + data->file = g_strdup (scanner->value.v_string); + + return G_TOKEN_NONE; +} + +guint +theme_parse_image (GScanner *scanner, + ThemeRcData *theme_data) +{ + guint token; + struct theme_image *data; + + data = NULL; + token = g_scanner_get_next_token (scanner); + if (token != TOKEN_IMAGE) + return TOKEN_IMAGE; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_LEFT_CURLY) + return G_TOKEN_LEFT_CURLY; + + data = g_malloc(sizeof(struct theme_image)); + data->function = -1; + data->file = NULL; + data->recolorable = 1; + data->border.left = 0; + data->border.right = 0; + data->border.top = 0; + data->border.bottom = 0; + data->detail = NULL; + data->state = GTK_STATE_NORMAL; + data->shadow = GTK_SHADOW_NONE; + + token = g_scanner_peek_next_token (scanner); + while (token != G_TOKEN_RIGHT_CURLY) + { + switch (token) + { + case TOKEN_FUNCTION: + token = theme_parse_function (scanner, data); + printf("func\n"); + break; + case TOKEN_FILE: + token = theme_parse_file (scanner, data); + break; + case TOKEN_RECOLORABLE: + token = theme_parse_recolorable (scanner, data); + break; + case TOKEN_BORDER: + token = theme_parse_border (scanner, &data->border); + break; + case TOKEN_DETAIL: + token = theme_parse_detail (scanner, data); + break; + case TOKEN_STATE: + token = theme_parse_state (scanner, data); + break; + case TOKEN_SHADOW: + token = theme_parse_shadow (scanner, data); + break; + default: + g_scanner_get_next_token (scanner); + token = G_TOKEN_RIGHT_CURLY; + break; + } + if (token != G_TOKEN_NONE) + { + /* error - cleanup for exit */ + return token; + } + token = g_scanner_peek_next_token (scanner); + } + + token = g_scanner_get_next_token (scanner); + + if (token != G_TOKEN_RIGHT_CURLY) + { + /* error - cleanup for exit */ + return G_TOKEN_RIGHT_CURLY; + } + + /* everything is fine now - insert yer cruft */ + return G_TOKEN_NONE; +} + +guint +theme_parse_rc_style (GScanner *scanner, + GtkRcStyle *rc_style) +{ + static GQuark scope_id = 0; + ThemeRcData *theme_data; + guint old_scope; + guint token; + gint i; + + /* Set up a new scope in this scanner. */ + + if (!scope_id) + scope_id = g_quark_from_string ("theme_engine"); + + /* If we bail out due to errors, we *don't* reset the scope, so the + * error messaging code can make sense of our tokens. + */ + old_scope = g_scanner_set_scope (scanner, scope_id); + + /* Now check if we already added our symbols to this scope + * (in some previous call to theme_parse_rc_style for the + * same scanner. + */ + + if (!g_scanner_lookup_symbol (scanner, theme_symbols[0].name)) + { + g_scanner_freeze_symbol_table (scanner); + for (i = 0; i < n_theme_symbols; i++) + g_scanner_scope_add_symbol (scanner, scope_id, + theme_symbols[i].name, + GINT_TO_POINTER (theme_symbols[i].token)); + g_scanner_thaw_symbol_table (scanner); + } + + /* We're ready to go, now parse the top level */ + + theme_data = g_new (ThemeRcData, 1); + theme_data->name = NULL; + + token = g_scanner_peek_next_token (scanner); + while (token != G_TOKEN_RIGHT_CURLY) + { + switch (token) + { + case TOKEN_IMAGE: + token = theme_parse_image (scanner, theme_data); + break; + default: + g_scanner_get_next_token (scanner); + token = G_TOKEN_RIGHT_CURLY; + break; + } + + if (token != G_TOKEN_NONE) + { + g_free (theme_data); + return token; + } + token = g_scanner_peek_next_token (scanner); + } + + g_scanner_get_next_token (scanner); + + rc_style->engine_data = theme_data; + g_scanner_set_scope (scanner, old_scope); + + return G_TOKEN_NONE; +} + +void +theme_merge_rc_style (GtkRcStyle *dest, + GtkRcStyle *src) +{ + ThemeRcData *src_data = src->engine_data; + ThemeRcData *dest_data = dest->engine_data; + + if (!dest_data) + { + dest_data = g_new (ThemeRcData, 1); + dest_data->name = NULL; + dest->engine_data = dest_data; + } + + if (dest_data->name == NULL) + dest_data->name = g_strdup (src_data->name); +} + +void +theme_rc_style_to_style (GtkStyle *style, + GtkRcStyle *rc_style) +{ + ThemeRcData *data = rc_style->engine_data; + ThemeStyleData *style_data; + + style_data = g_new (ThemeStyleData, 1); + style_data->name = g_strdup (data->name); + + style->klass = &th_default_class; + style->engine_data = style_data; + + g_print ("Theme theme: Creating style for \"%s\"\n", data->name); +} + +void +theme_duplicate_style (GtkStyle *dest, + GtkStyle *src) +{ + ThemeStyleData *dest_data; + ThemeStyleData *src_data = src->engine_data; + + dest_data = g_new (ThemeStyleData, 1); + dest_data->name = g_strdup (src_data->name); + + dest->engine_data = dest_data; + + g_print ("Theme theme: Duplicated style for \"%s\"\n", src_data->name); +} + +void +theme_realize_style (GtkStyle *style) +{ + ThemeStyleData *data = style->engine_data; + + g_print ("Theme theme: Realizing style for \"%s\"\n", data->name); +} + +void +theme_unrealize_style (GtkStyle *style) +{ + ThemeStyleData *data = style->engine_data; + + g_print ("Theme theme: Unrealizing style for \"%s\"\n", data->name); +} + +void +theme_destroy_rc_style (GtkRcStyle *rc_style) +{ + ThemeRcData *data = rc_style->engine_data; + + if (data) + { + g_free (data->name); + g_free (data); + } + + g_print ("Theme theme: Destroying rc style for \"%s\"\n", data->name); +} + +void +theme_destroy_style (GtkStyle *style) +{ + ThemeStyleData *data = style->engine_data; + + if (data) + { + g_free (data->name); + g_free (data); + } + + g_print ("Theme theme: Destroying style for \"%s\"\n", data->name); +} + +void +theme_set_background (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type) +{ + GdkPixmap *pixmap; + gint parent_relative; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if (style->bg_pixmap[state_type]) + { + if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE) + { + pixmap = NULL; + parent_relative = TRUE; + } + else + { + pixmap = style->bg_pixmap[state_type]; + parent_relative = FALSE; + } + + gdk_window_set_back_pixmap (window, pixmap, parent_relative); + } + else + gdk_window_set_background (window, &style->bg[state_type]); +} + +void +theme_init (GtkThemeEngine *engine) +{ + + printf("Theme2 Init\n"); + + engine->parse_rc_style = theme_parse_rc_style; + engine->merge_rc_style = theme_merge_rc_style; + engine->rc_style_to_style = theme_rc_style_to_style; + engine->duplicate_style = theme_duplicate_style; + engine->realize_style = theme_realize_style; + engine->unrealize_style = theme_unrealize_style; + engine->destroy_rc_style = theme_destroy_rc_style; + engine->destroy_style = theme_destroy_style; + engine->set_background = theme_set_background; + + gdk_imlib_init(); + + /* theme_config = th_dat.data = malloc(sizeof(ThemeConfig)); */ + /* theme_read_config(); */ +} + +void +theme_exit (void) +{ + printf("Theme2 Exit\n* Need to add memory deallocation code here *\n"); +} + diff --git a/themes/win95_theme_draw.c b/themes/win95_theme_draw.c index 8ac1af7e06..82eb9c9f30 100644 --- a/themes/win95_theme_draw.c +++ b/themes/win95_theme_draw.c @@ -752,19 +752,20 @@ draw_arrow (GtkStyle *style, else if (height == -1) gdk_window_get_size (window, NULL, &height); - half_width = width / 2; - half_height = height / 2; - xthik = style->klass->xthickness; ythik = style->klass->ythickness; + gc = style->black_gc; + if ((detail) && (!strcmp(detail,"menuitem"))) - border = 0; + { + border = 0; + gc = style->fg_gc[state_type]; + } if ((fill) && (border)) draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); - gc = style->black_gc; if (area) { @@ -772,48 +773,61 @@ draw_arrow (GtkStyle *style, } if (!border) { - xthik = 2; - ythik = 0; + x += 1; + y += 1; + width -= 2; + height -= 2; } + else + { + x += xthik; + y += ythik; + width -= xthik * 2; + height -= ythik * 2; + } + + half_width = width / 2; + half_height = height / 2; switch (arrow_type) { case GTK_ARROW_UP: - points[0].x = x + half_width; - points[0].y = y + ythik; - points[1].x = x + xthik; - points[1].y = y - ythik + height - 1; - points[2].x = x - xthik + width - 1; - points[2].y = y - ythik + height - 1; + points[0].x = x; + points[0].y = y + half_height + (half_width / 2); + points[1].x = x + width - 1; + points[1].y = y + half_height + (half_width / 2); + points[2].x = x + half_width; + points[2].y = y + half_height - (half_width / 2); + gdk_draw_polygon (window, gc, TRUE, points, 3); break; case GTK_ARROW_DOWN: - points[0].x = x + half_width; - points[0].y = y - ythik + height - 1; - points[1].x = x + xthik; - points[1].y = y + ythik; - points[2].x = x - xthik + width - 1; - points[2].y = y + ythik; + points[0].x = x; + points[0].y = y + half_height - (half_width / 2); + points[1].x = x + width - 1; + points[1].y = y + half_height - (half_width / 2); + points[2].x = x + half_width; + points[2].y = y + half_height + (half_width / 2); gdk_draw_polygon (window, gc, TRUE, points, 3); break; case GTK_ARROW_LEFT: - points[0].x = x + xthik; - points[0].y = y + half_height; - points[1].x = x - xthik + width - 1; - points[1].y = y - ythik + height - 1; - points[2].x = x - xthik + width - 1; - points[2].y = y + ythik; + points[0].x = x + half_width + (half_height / 2); + points[0].y = y; + points[1].x = x + half_width + (half_height / 2); + points[1].y = y + height - 1; + points[2].x = x + half_width - (half_height / 2); + points[2].y = y + half_height; gdk_draw_polygon (window, gc, TRUE, points, 3); break; case GTK_ARROW_RIGHT: - points[0].x = x - xthik + width - 1; - points[0].y = y + half_height; - points[1].x = x + xthik; - points[1].y = y + ythik; - points[2].x = x + xthik; - points[2].y = y - ythik + height - 1; + points[0].x = x + half_width - (half_height / 2); + points[0].y = y; + points[1].x = x + half_width - (half_height / 2); + points[1].y = y + height - 1; + points[2].x = x + half_width + (half_height / 2); + points[2].y = y + half_height; gdk_draw_polygon (window, gc, TRUE, points, 3); break; @@ -1093,6 +1107,19 @@ draw_box (GtkStyle *style, gdk_gc_set_clip_rectangle (style->bg_gc[GTK_STATE_SELECTED], NULL); } } + else if ((detail) && (!strcmp("menubar", detail))) + { + if (area) + { + gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area); + } + gdk_draw_rectangle(window, style->bg_gc[state_type], TRUE, + x, y, width, height); + if (area) + { + gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL); + } + } else { if ((!style->bg_pixmap[state_type]) ||