[Commit]
cairo-gtk-engine/src cge-draw.c, 1.2, 1.3 cge-style.c, 1.1,
1.2 cge-style.h, 1.1, 1.2
Julien Boulnois
commit at keithp.com
Sat Aug 2 17:28:39 PDT 2003
Committed by: jboulnois
Update of /local/src/CVS/cairo-gtk-engine/src
In directory home.keithp.com:/tmp/cvs-serv19939/src
Modified Files:
cge-draw.c cge-style.c cge-style.h
Log Message:
adding arrow style
Index: cge-draw.c
===================================================================
RCS file: /local/src/CVS/cairo-gtk-engine/src/cge-draw.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cge-draw.c 2 Aug 2003 05:21:09 -0000 1.2
+++ cge-draw.c 2 Aug 2003 23:28:37 -0000 1.3
@@ -36,27 +36,31 @@
*/
static void cge_draw_checked(cairo_t *xrs,
- GdkColor color,
- gdouble alpha,
- gint x,gint y,gint w, gint h,
- gdouble line_width
- );
+ GdkColor color,
+ gdouble alpha,
+ gint x,gint y,gint w, gint h,
+ gdouble line_width
+ );
-static void cge_draw_arrow(cairo_t *xrs,
- GdkColor c,
- gdouble alpha,
- gint x,gint y,gint w,gint h,
- gboolean fill,
- gdouble line_width,
- GtkArrowType at);
+static void cge_draw_arrow_from_rc(cairo_t *xrs,
+ GtkStyle * style,
+ GtkStateType state_type,
+ const gchar *detail,
+ GdkColor c,
+ gdouble alpha,
+ gint x,gint y,gint w,gint h,
+ gboolean fill,
+ gdouble line_width,
+ GtkArrowType at);
static void cge_draw_rectangle(cairo_t *xrs,
- GdkColor c,
- gdouble alpha,
- gint x,
- gint y,
- gint w,
- gint h);
+ GdkColor c,
+ gdouble alpha,
+ gint x,
+ gint y,
+ gint w,
+ gint h);
+
static void cge_draw_box(cairo_t *xrs,
GdkColor c,
cairo_surface_t *pattern,
@@ -531,48 +535,77 @@
-static void cge_draw_arrow(cairo_t *xrs,
- GdkColor c,
- gdouble alpha,
- gint x,gint y,gint w,gint h,
- gboolean fill,
- gdouble line_width,
- GtkArrowType at)
+static void cge_draw_arrow_from_rc(cairo_t *xrs,
+ GtkStyle * style,
+ GtkStateType state_type,
+ const gchar *detail,
+ GdkColor c,
+ gdouble alpha,
+ gint x,gint y,gint w,gint h,
+ gboolean fill,
+ gdouble line_width,
+ GtkArrowType at)
{
gdouble r,g,b;
cairo_save(xrs);
cairo_new_path(xrs);
cairo_set_line_width(xrs, line_width);
cairo_set_line_join (xrs, CAIRO_LINE_JOIN_ROUND);
+ gdouble rt;
+ switch(THEME_DATA(style)->arrow_style)
+ {
+ case CGE_ARROW_NORMAL:
+ rt=h/4 - h/10;
+ break;
+ case CGE_ARROW_SIMPLE:
+ rt=h/4;
+ break;
+ default:
+ break;
+ }
switch(at)
{
case GTK_ARROW_UP:
cairo_translate(xrs,(double)x,(double)y);
- cairo_move_to(xrs, (double)w/2, 0);
+ cairo_move_to(xrs, (double)w/2, rt);
break;
case GTK_ARROW_DOWN:
cairo_translate(xrs,(double)x,(double)y);
- cairo_move_to(xrs, (double)w/2, (double)h+(double)h/5);
- cairo_rotate (xrs, M_PI);
+ cairo_move_to(xrs, (double)w/2, h-rt);
+ cairo_rotate (xrs, M_PI);
break;
case GTK_ARROW_LEFT:
cairo_translate(xrs,(double)x,(double)y);
- cairo_move_to(xrs, 0, (double)h/2);
+ cairo_move_to(xrs, rt, (double)h/2);
cairo_rotate (xrs, -M_PI_2);
break;
case GTK_ARROW_RIGHT:
cairo_translate(xrs,(double)x,(double)y);
- cairo_move_to(xrs, (double)w, (double)h/2);
+ cairo_move_to(xrs, (double)w-rt, (double)h/2);
cairo_rotate (xrs, M_PI_2);
break;
}
- cairo_rel_line_to(xrs, (double) w/2, (double)h);
- cairo_rel_line_to(xrs, -(double)w/2, (double)h/5);
- cairo_rel_line_to(xrs, -(double)w/2, -(double)h/5);
+
+ switch(THEME_DATA(style)->arrow_style)
+ {
+ case CGE_ARROW_NORMAL:
+ cairo_rel_line_to(xrs, (double) w/2, (double)h/2);
+ cairo_rel_line_to(xrs, -(double)w/2, (double)h/5);
+ cairo_rel_line_to(xrs, -(double)w/2, -(double)h/5);
+ break;
+ case CGE_ARROW_SIMPLE:
+ cairo_rel_line_to(xrs, (double) w/2, (double)h/2);
+ cairo_rel_line_to(xrs, -(double)w,0);
+ break;
+ default:
+ break;
+ }
+
+ //printf("%i\n",THEME_DATA(style)->arrow_style);
color_gdk_to_rgb(c,&r,&g,&b);
cairo_set_rgb_color(xrs, r, g, b);
@@ -1299,8 +1332,22 @@
xrs=cairo_create();
cge_gdk(xrs,window);
- cge_draw_arrow(xrs,style->text[state_type],1,x+1,y,width-2,(height-2)/2,TRUE,1.5,GTK_ARROW_UP);
- cge_draw_arrow(xrs,style->text[state_type],1,x+1,y+3+(height-2)/2,width-2,(height-2)/2,TRUE,1.5,GTK_ARROW_DOWN);
+ cge_draw_arrow_from_rc(xrs,
+ style,
+ state_type,
+ detail,
+ style->text[state_type],
+ 1,
+ x+1,y,width-2,(height-2)/2,
+ TRUE,1.5,GTK_ARROW_UP);
+ cge_draw_arrow_from_rc(xrs,
+ style,
+ state_type,
+ detail,
+ style->text[state_type],
+ 1,
+ x+1,y+3+(height-2)/2,width-2,(height-2)/2,
+ TRUE,1.5,GTK_ARROW_DOWN);
cairo_destroy(xrs);
}
@@ -1437,8 +1484,15 @@
xrs=cairo_create();
cge_gdk(xrs,window);
- cge_draw_arrow(xrs,style->text[state_type],1,x+1,y+1,width-2,height-2,TRUE,1.5,arrow_type);
-
+ cge_draw_arrow_from_rc(xrs,
+ style,
+ state_type,
+ detail,
+ style->text[state_type],
+ 1,
+ x,y,width,height,
+ TRUE,1.5,arrow_type);
+
cairo_destroy(xrs);
}
Index: cge-style.c
===================================================================
RCS file: /local/src/CVS/cairo-gtk-engine/src/cge-style.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cge-style.c 1 Aug 2003 14:56:20 -0000 1.1
+++ cge-style.c 2 Aug 2003 23:28:37 -0000 1.2
@@ -21,6 +21,7 @@
TOKEN_FILL,
TOKEN_LINE,
TOKEN_MODE,
+ TOKEN_ARROW,
TOKEN_ROUND_WIDTH,
@@ -41,15 +42,16 @@
theme_symbols[] =
{
- { "style", TOKEN_STYLE },
- { "detail", TOKEN_DETAIL },
+ { "style", TOKEN_STYLE },
+ { "detail", TOKEN_DETAIL },
{ "fill", TOKEN_FILL },
{ "line", TOKEN_LINE },
{ "mode", TOKEN_MODE },
+ { "arrow", TOKEN_ARROW },
{ "round_width", TOKEN_ROUND_WIDTH },
{ "line_width", TOKEN_LINE_WIDTH },
- { "gradient_direction", TOKEN_GRADIENT_DIRECTION },
- { "color", TOKEN_COLOR },
+ { "gradient_direction", TOKEN_GRADIENT_DIRECTION },
+ { "color", TOKEN_COLOR },
};
static guint n_theme_symbols = sizeof(theme_symbols) / sizeof(theme_symbols[0]);
@@ -101,6 +103,22 @@
return TRUE;
}
+static gboolean
+TranslateArrowStyle (gchar * str, gint *retval)
+{
+#define is_enum(XX) (g_ascii_strncasecmp(str, XX, strlen(XX))==0)
+ if is_enum("normal")
+ *retval = CGE_ARROW_NORMAL;
+ else if (is_enum("simple"))
+ *retval = CGE_ARROW_SIMPLE;
+ else if (is_enum("file"))
+ *retval = CGE_ARROW_FILE;
+ else
+ return FALSE;
+ return TRUE;
+}
+
+
static guint
theme_parse_custom_enum (GScanner *scanner,
GTokenType wanted_token,
@@ -436,6 +454,8 @@
cge_rc_init_fill_style(&style->styles[i].fill_style);
cge_rc_init_line_style(&style->styles[i].line_style);
}
+
+ style->arrow_style=CGE_ARROW_NORMAL;
/* style->fill_style.fill_mode=CGE_FILL_SOLID;
style->fill_style.round_width=4;
@@ -515,6 +535,9 @@
case TOKEN_LINE:
token = theme_parse_line (settings, scanner, TOKEN_LINE, &cge_style->styles[0].line_style);
break;
+ case TOKEN_ARROW:
+ token = theme_parse_custom_enum(scanner, TOKEN_ARROW, TranslateArrowStyle, CGE_ARROW_NORMAL, &cge_style->arrow_style);
+ break;
default:
g_scanner_get_next_token (scanner);
token = G_TOKEN_RIGHT_CURLY;
@@ -560,6 +583,7 @@
dest_data->styles[i]=src_data->styles[i];
}
+ dest_data->arrow_style=src_data->arrow_style;
SET_THEME_DATA(dest, dest_data);
}
Index: cge-style.h
===================================================================
RCS file: /local/src/CVS/cairo-gtk-engine/src/cge-style.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cge-style.h 1 Aug 2003 14:56:20 -0000 1.1
+++ cge-style.h 2 Aug 2003 23:28:37 -0000 1.2
@@ -61,7 +61,15 @@
CGE_DIRECTION_HORIZONTAL
}cge_direction;
+typedef enum
+ {
+ CGE_ARROW_NORMAL=0,
+ CGE_ARROW_SIMPLE,
+ CGE_ARROW_WONDERLAND,
+ /* others ... */
+ CGE_ARROW_FILE
+ }cge_arrow_style;
#define MAX_GRADIENT_COLORS 10
#define MAX_STYLES 10
@@ -111,6 +119,8 @@
struct _CgeRCStyle {
GtkRcStyle parent_instance;
+
+ cge_arrow_style arrow_style;
cge_style styles[MAX_STYLES];
More information about the Commit
mailing list