scrollbar sizes, button sizes, paned sizes

This commit is contained in:
cinamod 2003-09-08 13:53:25 +00:00
parent 0e82f3df02
commit 96196a4e47
2 changed files with 79 additions and 50 deletions

View File

@ -1,3 +1,7 @@
2003-09-08 Dom Lachowicz <cinamod@hotmail.com>
* src/wimp_style.c: Honor scrollbar sizes, radio/check button sizes, paned sizes
2003-09-03 Dom Lachowicz <cinamod@hotmail.com> 2003-09-03 Dom Lachowicz <cinamod@hotmail.com>
* src/wimp_style.c: Honor tooltip color, font * src/wimp_style.c: Honor tooltip color, font

View File

@ -156,55 +156,49 @@ sys_font_to_pango_font (SystemFontType type, char * buf)
const char * weight; const char * weight;
const char * style; const char * style;
/*
TODO: I don't think that pango font descriptions let you set these
BYTE lfUnderline; underline=single|none
BYTE lfStrikeOut; strikethrough=true|false
*/
if (get_system_font(type, &lf)) if (get_system_font(type, &lf))
{ {
switch (lf.lfWeight) { switch (lf.lfWeight) {
case FW_THIN: case FW_THIN:
case FW_EXTRALIGHT: case FW_EXTRALIGHT:
weight = "ultralight"; weight = "ultralight";
break; break;
case FW_LIGHT: case FW_LIGHT:
weight = "light"; weight = "light";
break; break;
case FW_SEMIBOLD: case FW_SEMIBOLD:
case FW_BOLD: case FW_BOLD:
weight = "bold"; weight = "bold";
break; break;
case FW_ULTRABOLD: case FW_ULTRABOLD:
weight = "ultrabold"; weight = "ultrabold";
break; break;
case FW_HEAVY: case FW_HEAVY:
weight = "heavy"; weight = "heavy";
default: default:
weight = "normal"; weight = "normal";
break; break;
} }
if (lf.lfItalic) if (lf.lfItalic)
style="italic"; style="italic";
else else
style="normal"; style="normal";
pt_size = -MulDiv(lf.lfHeight, 72, pt_size = -MulDiv(lf.lfHeight, 72,
GetDeviceCaps(GetDC(GetDesktopWindow()), GetDeviceCaps(GetDC(GetDesktopWindow()),
LOGPIXELSY)); LOGPIXELSY));
sprintf(buf, "%s %s %s %d", lf.lfFaceName, style, weight, pt_size); sprintf(buf, "%s %s %s %d", lf.lfFaceName, style, weight, pt_size);
return buf; return buf;
} }
return NULL; return NULL;
} }
static void static void
@ -213,9 +207,7 @@ setup_system_font(GtkStyle *style)
char buf[256], * font; /* It's okay, lfFaceName is smaller than 32 chars */ char buf[256], * font; /* It's okay, lfFaceName is smaller than 32 chars */
if ((font = sys_font_to_pango_font(MESSAGE_FONT, buf)) != NULL) if ((font = sys_font_to_pango_font(MESSAGE_FONT, buf)) != NULL)
{ style->font_desc = pango_font_description_from_string(font);
style->font_desc = pango_font_description_from_string(font);
}
} }
static void static void
@ -243,6 +235,9 @@ setup_system_styles(GtkStyle *style)
GdkColor btn_fore; GdkColor btn_fore;
GdkColor progress_back; GdkColor progress_back;
NONCLIENTMETRICS nc;
gint paned_size = 15;
int i; int i;
/* Default forgeground */ /* Default forgeground */
@ -292,12 +287,6 @@ setup_system_styles(GtkStyle *style)
/* progress bar background color */ /* progress bar background color */
sys_color_to_gtk_color(COLOR_HIGHLIGHT, &progress_back); sys_color_to_gtk_color(COLOR_HIGHLIGHT, &progress_back);
/* TODO: scrollbars
http://lxr.mozilla.org/mozilla/source/gfx/src/windows/nsNativeThemeWin.cpp#1317
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getsystemmetrics.asp
http://developer.gnome.org/doc/API/2.0/gtk/GtkRange.html
*/
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
{ {
sys_color_to_gtk_color(COLOR_3DSHADOW, &style->dark[i]); sys_color_to_gtk_color(COLOR_3DSHADOW, &style->dark[i]);
@ -314,7 +303,7 @@ setup_system_styles(GtkStyle *style)
/* Enable coloring for menus. */ /* Enable coloring for menus. */
font_ptr = sys_font_to_pango_font (MENU_FONT,font_buf); font_ptr = sys_font_to_pango_font (MENU_FONT,font_buf);
sprintf(buf, "style \"wimp-menu\"\n" sprintf(buf, "style \"wimp-menu\" = \"wimp-default\"\n"
"{fg[PRELIGHT] = { %d, %d, %d }\n" "{fg[PRELIGHT] = { %d, %d, %d }\n"
"bg[PRELIGHT] = { %d, %d, %d }\n" "bg[PRELIGHT] = { %d, %d, %d }\n"
"text[PRELIGHT] = { %d, %d, %d }\n" "text[PRELIGHT] = { %d, %d, %d }\n"
@ -347,7 +336,7 @@ setup_system_styles(GtkStyle *style)
/* enable tooltip fonts */ /* enable tooltip fonts */
font_ptr = sys_font_to_pango_font (STATUS_FONT,font_buf); font_ptr = sys_font_to_pango_font (STATUS_FONT,font_buf);
sprintf(buf, "style \"wimp-tooltips-caption\"\n" sprintf(buf, "style \"wimp-tooltips-caption\" = \"wimp-default\"\n"
"{fg[NORMAL] = { %d, %d, %d }\n" "{fg[NORMAL] = { %d, %d, %d }\n"
"%s = \"%s\"\n" "%s = \"%s\"\n"
"}widget \"gtk-tooltips.GtkLabel\" style \"wimp-tooltips-caption\"\n", "}widget \"gtk-tooltips.GtkLabel\" style \"wimp-tooltips-caption\"\n",
@ -358,7 +347,7 @@ setup_system_styles(GtkStyle *style)
(font_ptr ? font_ptr : " font name should go here")); (font_ptr ? font_ptr : " font name should go here"));
gtk_rc_parse_string(buf); gtk_rc_parse_string(buf);
sprintf(buf, "style \"wimp-tooltips\"\n" sprintf(buf, "style \"wimp-tooltips\" = \"wimp-default\"\n"
"{bg[NORMAL] = { %d, %d, %d }\n" "{bg[NORMAL] = { %d, %d, %d }\n"
"}widget \"gtk-tooltips*\" style \"wimp-tooltips\"\n", "}widget \"gtk-tooltips*\" style \"wimp-tooltips\"\n",
tooltip_back.red, tooltip_back.red,
@ -368,7 +357,7 @@ setup_system_styles(GtkStyle *style)
/* enable font theming for status bars */ /* enable font theming for status bars */
font_ptr = sys_font_to_pango_font (STATUS_FONT,font_buf); font_ptr = sys_font_to_pango_font (STATUS_FONT,font_buf);
sprintf(buf, "style \"wimp-statusbar\"\n" sprintf(buf, "style \"wimp-statusbar\" = \"wimp-default\"\n"
"{%s = \"%s\"\n" "{%s = \"%s\"\n"
"}widget_class \"*GtkStatusbar*\" style \"wimp-statusbar\"\n", "}widget_class \"*GtkStatusbar*\" style \"wimp-statusbar\"\n",
(font_ptr ? "font_name" : "#"), (font_ptr ? "font_name" : "#"),
@ -377,7 +366,7 @@ setup_system_styles(GtkStyle *style)
/* enable coloring for text on buttons /* enable coloring for text on buttons
TODO: use GetThemeMetric for the border and outside border */ TODO: use GetThemeMetric for the border and outside border */
sprintf(buf, "style \"wimp-button\"\n" sprintf(buf, "style \"wimp-button\" = \"wimp-default\"\n"
"fg[NORMAL] = { %d, %d, %d }\n" "fg[NORMAL] = { %d, %d, %d }\n"
"default_border = { 1, 1, 1, 1 }\n" "default_border = { 1, 1, 1, 1 }\n"
"default_outside_border = { 0, 0, 0, 0 }\n" "default_outside_border = { 0, 0, 0, 0 }\n"
@ -390,13 +379,49 @@ setup_system_styles(GtkStyle *style)
gtk_rc_parse_string(buf); gtk_rc_parse_string(buf);
/* enable coloring for progress bars */ /* enable coloring for progress bars */
sprintf(buf, "style \"wimp-progress\"\n" sprintf(buf, "style \"wimp-progress\" = \"wimp-default\"\n"
"{bg[PRELIGHT] = { %d, %d, %d }\n" "{bg[PRELIGHT] = { %d, %d, %d }\n"
"}widget_class \"*GtkProgress*\" style \"wimp-progress\"\n", "}widget_class \"*GtkProgress*\" style \"wimp-progress\"\n",
progress_back.red, progress_back.red,
progress_back.green, progress_back.green,
progress_back.blue); progress_back.blue);
gtk_rc_parse_string(buf); gtk_rc_parse_string(buf);
/* scrollbar thumb width and height */
sprintf(buf, "style \"wimp-vscrollbar\" = \"wimp-default\"\n"
"{GtkRange::slider-width = %d\n"
"GtkRange::stepper-size = %d\n"
"GtkRange::stepper-spacing = 0\n"
"GtkRange::trough_border = 0\n"
"}widget_class \"*GtkVScrollbar*\" style \"wimp-vscrollbar\"\n",
GetSystemMetrics(SM_CYVTHUMB),
GetSystemMetrics(SM_CXVSCROLL));
gtk_rc_parse_string(buf);
sprintf(buf, "style \"wimp-hscrollbar\" = \"wimp-default\"\n"
"{GtkRange::slider-width = %d\n"
"GtkRange::stepper-size = %d\n"
"GtkRange::stepper-spacing = 0\n"
"GtkRange::trough_border = 0\n"
"}widget_class \"*GtkHScrollbar*\" style \"wimp-hscrollbar\"\n",
GetSystemMetrics(SM_CXHTHUMB),
GetSystemMetrics(SM_CYHSCROLL));
gtk_rc_parse_string(buf);
/* radio/check button sizes */
sprintf(buf, "style \"wimp-checkbutton\" = \"wimp-default\"\n"
"{GtkCheckButton::indicator-size = 13\n"
"}widget_class \"*GtkCheckButton*\" style \"wimp-checkbutton\"\n");
gtk_rc_parse_string(buf);
/* the width/height of the paned resizer grippies */
nc.cbSize = sizeof(nc);
if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(nc), &nc, 0))
paned_size = abs(nc.lfStatusFont.lfHeight) + 4;
sprintf(buf, "style \"wimp-paned\" = \"wimp-default\"\n"
"{GtkPaned::handle-size = %d\n"
"}widget_class \"*GtkPaned*\" style \"wimp-paned\"\n", paned_size);
gtk_rc_parse_string(buf);
} }
static gboolean static gboolean
@ -1186,7 +1211,7 @@ draw_tab (GtkStyle *style,
} }
/* this is an undefined magic value that, according to the mozilla folks, /* this is an undefined magic value that, according to the mozilla folks,
worked for all the various themes that they tried */ worked for all the various themes that they tried */
#define XP_EDGE_SIZE 2 #define XP_EDGE_SIZE 2
static void static void