From: <kr_...@us...> - 2003-08-25 20:41:12
|
Update of /cvsroot/htoolkit/port/src/cbits/GTK In directory sc8-pr-cvs1:/tmp/cvs-serv29626/src/cbits/GTK Modified Files: Canvas.c Font.c Log Message: In this commit are implemented functions osGetTextColor, osGetWindowColor, osGetDialogColor. The osDefaultFontDef function now returns the default font for gnome application. The osDefaultFontDef and similar functions now returns new allocated string which is deallocated from Haskell world. Index: Canvas.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Canvas.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Canvas.c 24 Aug 2003 19:02:45 -0000 1.13 --- Canvas.c 25 Aug 2003 20:41:08 -0000 1.14 *************** *** 681,682 **** --- 681,711 ---- *dv = 1; } /* osGetScaleFactor */ + + unsigned int gdk_color_to_rgb(GdkColor color) + { + return (color.red/257) | ((color.green/257) << 8) | ((color.blue/257) << 16); + } + + unsigned int osGetDialogColor() + { + GtkStyle *style = gtk_style_new(); + int rgb = gdk_color_to_rgb(style->bg[GTK_STATE_NORMAL]); + gtk_style_unref(style); + return rgb; + } + + unsigned int osGetWindowColor() + { + GtkStyle *style = gtk_style_new(); + int rgb = gdk_color_to_rgb(style->base[GTK_STATE_NORMAL]); + gtk_style_unref(style); + return rgb; + } + + unsigned int osGetTextColor() + { + GtkStyle *style = gtk_style_new(); + int rgb = gdk_color_to_rgb(style->fg[GTK_STATE_NORMAL]); + gtk_style_unref(style); + return rgb; + } Index: Font.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Font.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Font.c 24 Aug 2003 19:02:45 -0000 1.5 --- Font.c 25 Aug 2003 20:41:08 -0000 1.6 *************** *** 72,79 **** switch (pango_font_description_get_style(desc)) { ! case PANGO_STYLE_NORMAL: *(p++) = 0; break; ! case PANGO_STYLE_OBLIQUE: *(p++) = 1; break; ! case PANGO_STYLE_ITALIC: *(p++) = 2; break; ! default: *(p++) = -1; break; } *(p++) = 0; --- 72,79 ---- switch (pango_font_description_get_style(desc)) { ! case PANGO_STYLE_NORMAL: *(p++) = FONT_NORMAL; break; ! case PANGO_STYLE_OBLIQUE: *(p++) = FONT_ITALIC; break; ! case PANGO_STYLE_ITALIC: *(p++) = FONT_OBLIQUE; break; ! default: *(p++) = FONT_NORMAL; break; } *(p++) = 0; *************** *** 199,211 **** void osDefaultFontDef(char **face, int *size, int *weight, int *style) { ! *face = "helvetica"; ! *size = 12; ! *weight = 500; ! *style = 0; } void osSerifFontDef(char **face, int *size, int *weight, int *style) { ! *face = "times"; *size = 10; *weight = 400; --- 199,220 ---- void osDefaultFontDef(char **face, int *size, int *weight, int *style) { ! GtkStyle *gtkstyle = gtk_style_new(); ! *face = strdup(pango_font_description_get_family (gtkstyle->font_desc)); ! *size = pango_font_description_get_size (gtkstyle->font_desc)/PANGO_SCALE; ! *weight = pango_font_description_get_weight(gtkstyle->font_desc); ! ! switch (pango_font_description_get_style(gtkstyle->font_desc)) ! { ! case PANGO_STYLE_NORMAL: *style = FONT_NORMAL; break; ! case PANGO_STYLE_OBLIQUE: *style = FONT_ITALIC; break; ! case PANGO_STYLE_ITALIC: *style = FONT_OBLIQUE; break; ! default: *style = FONT_NORMAL; break; ! } ! gtk_style_unref(gtkstyle); } void osSerifFontDef(char **face, int *size, int *weight, int *style) { ! *face = strdup("times"); *size = 10; *weight = 400; *************** *** 215,219 **** void osSansSerifFontDef(char **face, int *size, int *weight, int *style) { ! *face = "helvetica"; *size = 10; *weight = 500; --- 224,228 ---- void osSansSerifFontDef(char **face, int *size, int *weight, int *style) { ! *face = strdup("Sans"); *size = 10; *weight = 500; *************** *** 223,227 **** void osSmallFontDef(char **face, int *size, int *weight, int *style) { ! *face = "helvetica"; *size = 7; *weight = 500; --- 232,236 ---- void osSmallFontDef(char **face, int *size, int *weight, int *style) { ! *face = strdup("helvetica"); *size = 7; *weight = 500; *************** *** 231,235 **** void osNonProportionalFontDef(char **face, int *size, int *weight, int *style) { ! *face = "fixed"; *size = 10; *weight = 400; --- 240,244 ---- void osNonProportionalFontDef(char **face, int *size, int *weight, int *style) { ! *face = strdup("fixed"); *size = 10; *weight = 400; *************** *** 239,243 **** void osSymbolFontDef(char **face, int *size, int *weight, int *style) { ! *face = "symbol"; *size = 10; *weight = 400; --- 248,252 ---- void osSymbolFontDef(char **face, int *size, int *weight, int *style) { ! *face = strdup("symbol"); *size = 10; *weight = 400; |