re-sync with gtk-wimp cvs

This commit is contained in:
Dom Lachowicz 2005-07-28 12:24:25 +00:00
parent 48d7e1ca92
commit 3d14f381b7
8 changed files with 371 additions and 207 deletions

View File

@ -1,3 +1,13 @@
2005-07-28 Dom Lachowicz <cinamod@hotmail.com>
* modules/engines/ms-windows/*: Re-sync with gtk-wimp CVS. Notable
changes include: menu/toolbars have a gradient applied to them; better
handling of menu/toolbar shadows, tracking theme settings;
sliders/scales now use XP theming; status bar grippies drawn properly;
convincing toolbar grippies are drawn for the Win2k theme; notebook
tabs now have that orange stripe across their top; a host of scrollbar
bugs are fixed
2005-07-27 Tor Lillqvist <tml@novell.com>
* gdk/win32/gdkmain-win32.c (_gdk_win32_psstyle_to_string): Handle

View File

@ -1,3 +1,13 @@
2005-07-28 Dom Lachowicz <cinamod@hotmail.com>
* modules/engines/ms-windows/*: Re-sync with gtk-wimp CVS. Notable
changes include: menu/toolbars have a gradient applied to them; better
handling of menu/toolbar shadows, tracking theme settings;
sliders/scales now use XP theming; status bar grippies drawn properly;
convincing toolbar grippies are drawn for the Win2k theme; notebook
tabs now have that orange stripe across their top; a host of scrollbar
bugs are fixed
2005-07-27 Tor Lillqvist <tml@novell.com>
* gdk/win32/gdkmain-win32.c (_gdk_win32_psstyle_to_string): Handle

View File

@ -1,3 +1,13 @@
2005-07-28 Dom Lachowicz <cinamod@hotmail.com>
* modules/engines/ms-windows/*: Re-sync with gtk-wimp CVS. Notable
changes include: menu/toolbars have a gradient applied to them; better
handling of menu/toolbar shadows, tracking theme settings;
sliders/scales now use XP theming; status bar grippies drawn properly;
convincing toolbar grippies are drawn for the Win2k theme; notebook
tabs now have that orange stripe across their top; a host of scrollbar
bugs are fixed
2005-07-27 Tor Lillqvist <tml@novell.com>
* gdk/win32/gdkmain-win32.c (_gdk_win32_psstyle_to_string): Handle

View File

@ -30,11 +30,6 @@ style "msw-default"
GtkTreeView::allow-rules = 0
GtkTreeView::expander-size = 12
# etched-in is closer to how Win32's explorer.exe does things, but it makes apps with
# multiple toolbars or a menubar and a toolbar look like garbage
GtkToolbar::shadow-type = out
GtkHandleBox::shadow-type = out
engine "wimp"
{
}

View File

@ -24,6 +24,7 @@
* Useful resources:
*
* http://lxr.mozilla.org/mozilla/source/gfx/src/windows/nsNativeThemeWin.cpp
* http://lxr.mozilla.org/seamonkey/source/widget/src/windows/nsLookAndFeel.cpp
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/userex/functions/drawthemebackground.asp
*/
@ -66,48 +67,48 @@ typedef enum {
#define PART_SIZE 13
static const char check_aa_bits[] = {
static const guint8 check_aa_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static const char check_base_bits[] = {
static const guint8 check_base_bits[] = {
0x00,0x00,0x00,0x00,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0x00,0x00,0x00,0x00};
static const char check_black_bits[] = {
static const guint8 check_black_bits[] = {
0x00,0x00,0xfe,0x0f,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00};
static const char check_dark_bits[] = {
static const guint8 check_dark_bits[] = {
0xff,0x1f,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00};
static const char check_light_bits[] = {
static const guint8 check_light_bits[] = {
0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0xfe,0x1f};
static const char check_mid_bits[] = {
static const guint8 check_mid_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
0x08,0x00,0x08,0x00,0x08,0x00,0x08,0xfc,0x0f,0x00,0x00};
static const char check_text_bits[] = {
static const guint8 check_text_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x03,0x88,0x03,0xd8,0x01,0xf8,
0x00,0x70,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static const char radio_base_bits[] = {
static const guint8 radio_base_bits[] = {
0x00,0x00,0x00,0x00,0xf0,0x01,0xf8,0x03,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
0x07,0xfc,0x07,0xf8,0x03,0xf0,0x01,0x00,0x00,0x00,0x00};
static const char radio_black_bits[] = {
static const guint8 radio_black_bits[] = {
0x00,0x00,0xf0,0x01,0x0c,0x02,0x04,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static const char radio_dark_bits[] = {
static const guint8 radio_dark_bits[] = {
0xf0,0x01,0x0c,0x06,0x02,0x00,0x02,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
0x00,0x01,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00};
static const char radio_light_bits[] = {
static const guint8 radio_light_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
0x10,0x00,0x10,0x00,0x08,0x00,0x08,0x0c,0x06,0xf0,0x01};
static const char radio_mid_bits[] = {
static const guint8 radio_mid_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
0x08,0x00,0x08,0x00,0x04,0x0c,0x06,0xf0,0x01,0x00,0x00};
static const char radio_text_bits[] = {
static const guint8 radio_text_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00,0xf0,0x01,0xf0,0x01,0xf0,
0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static struct {
const char *bits;
const guint8 *bits;
GdkBitmap *bmap;
} parts[] = {
{ check_aa_bits, NULL },
@ -129,7 +130,7 @@ static gboolean
get_system_font(XpThemeClass klazz, XpThemeFont type, LOGFONT *out_lf)
{
#if 0
/* TODO: this crashes. need to figure out why and how to fix it */
/* TODO: this causes crashes later because the font name is in UCS2, and the pango fns don't deal with that gracefully */
if (xp_theme_get_system_font(klazz, type, out_lf))
return TRUE;
else
@ -256,8 +257,7 @@ get_family_name (LOGFONT *lfp, HDC pango_win32_hdc)
gchar *string = NULL;
gchar *name;
gint i, l;
gsize nbytes;
size_t i, l, nbytes;
/* If lfFaceName is ASCII, assume it is the common (English) name
* for the font. Is this valid? Do some TrueType fonts have
@ -275,7 +275,7 @@ get_family_name (LOGFONT *lfp, HDC pango_win32_hdc)
if ((hfont = CreateFontIndirect (lfp)) == NULL)
goto fail0;
if ((oldhfont = SelectObject (pango_win32_hdc, hfont)) == NULL)
if ((oldhfont = (HFONT)SelectObject (pango_win32_hdc, hfont)) == NULL)
goto fail1;
if (!pango_win32_get_name_header (pango_win32_hdc, &header))
@ -553,9 +553,6 @@ get_system_metric(XpThemeClass klazz, int id)
static void
setup_msw_rc_style(void)
{
/* TODO: Owen says:
"If your setup_system_styles() function called gtk_rc_parse_string(), then you are just piling a new set of strings on top each time the theme changes .. the old ones won't be removed" */
char buf[1024], font_buf[256], *font_ptr;
GdkColor menu_color;
@ -571,6 +568,8 @@ setup_msw_rc_style(void)
GdkColor base_prelight;
GdkColor text_prelight;
gboolean xp_theme = xp_theme_is_active();
/* Prelight */
sys_color_to_gtk_color(XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHTTEXT, &fg_prelight);
sys_color_to_gtk_color(XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT, &bg_prelight);
@ -633,11 +632,22 @@ setup_msw_rc_style(void)
"style \"msw-menu-bar\" = \"msw-menu\"\n"
"{\n"
"bg[NORMAL] = { %d, %d, %d }\n"
"GtkMenuBar::shadow-type = out\n"
"GtkMenuBar::shadow-type = %s\n"
"}widget_class \"*MenuBar*\" style \"msw-menu-bar\"\n",
btn_face.red,
btn_face.green,
btn_face.blue);
btn_face.blue,
(xp_theme ? "etched-in" : "out"));
gtk_rc_parse_string(buf);
g_snprintf(buf, sizeof (buf),
"style \"msw-toolbar\" = \"msw-default\"\n"
"{\n"
"GtkHandleBox::shadow-type = %s\n"
"GtkToolbar::shadow-type = %s\n"
"}widget_class \"*HandleBox*\" style \"msw-toolbar\"\n",
(xp_theme ? "none" : "out"),
(xp_theme ? "none" : "out"));
gtk_rc_parse_string(buf);
/* enable tooltip fonts */
@ -715,9 +725,12 @@ setup_msw_rc_style(void)
"GtkRange::stepper-size = %d\n"
"GtkRange::stepper-spacing = 0\n"
"GtkRange::trough_border = 0\n"
"}widget_class \"*VScrollbar*\" style \"msw-vscrollbar\"\n",
"GtkScale::slider-length = %d\n"
"}widget_class \"*VScrollbar*\" style \"msw-vscrollbar\"\n"
"widget_class \"*VScale*\" style \"msw-vscrollbar\"\n",
GetSystemMetrics(SM_CYVTHUMB),
get_system_metric(XP_THEME_CLASS_SCROLLBAR, SM_CXVSCROLL));
get_system_metric(XP_THEME_CLASS_SCROLLBAR, SM_CXVSCROLL),
11);
gtk_rc_parse_string(buf);
g_snprintf(buf, sizeof (buf),
@ -726,9 +739,12 @@ setup_msw_rc_style(void)
"GtkRange::stepper-size = %d\n"
"GtkRange::stepper-spacing = 0\n"
"GtkRange::trough_border = 0\n"
"}widget_class \"*HScrollbar*\" style \"msw-hscrollbar\"\n",
"GtkScale::slider-length = %d\n"
"}widget_class \"*HScrollbar*\" style \"msw-hscrollbar\"\n"
"widget_class \"*HScale*\" style \"msw-hscrollbar\"\n",
GetSystemMetrics(SM_CXHTHUMB),
get_system_metric(XP_THEME_CLASS_SCROLLBAR, SM_CYHSCROLL));
get_system_metric(XP_THEME_CLASS_SCROLLBAR, SM_CYHSCROLL),
11);
gtk_rc_parse_string(buf);
/* radio/check button sizes */
@ -1405,13 +1421,13 @@ draw_box (GtkStyle *style,
return;
}
}
else if (detail && !strcmp (detail, "slider"))
{
if (GTK_IS_SCROLLBAR(widget))
{
GtkScrollbar * scrollbar = GTK_SCROLLBAR(widget);
gboolean is_v = GTK_IS_VSCROLLBAR(widget);
if (xp_theme_draw(window,
is_v
? XP_THEME_ELEMENT_SCROLLBAR_V
@ -1479,8 +1495,7 @@ draw_box (GtkStyle *style,
{
gboolean is_vertical = GTK_IS_VSCROLLBAR(widget);
if (GTK_IS_RANGE(widget)
&& xp_theme_draw(window,
if (xp_theme_draw(window,
is_vertical
? XP_THEME_ELEMENT_TROUGH_V
: XP_THEME_ELEMENT_TROUGH_H,
@ -1526,14 +1541,23 @@ draw_box (GtkStyle *style,
{
gboolean is_vertical = GTK_IS_VSCALE(widget);
if(!xp_theme_is_active ()) {
parent_class->draw_box (style, window, state_type, GTK_SHADOW_NONE, area,
widget, detail, x, y, width, height);
}
if(is_vertical) {
if(xp_theme_draw(window, XP_THEME_ELEMENT_SCALE_TROUGH_V, style, (2 * x + width)/2, y, 2, height, state_type, area))
return;
if(is_vertical)
parent_class->draw_box(style, window, state_type, GTK_SHADOW_ETCHED_IN, area, NULL, NULL, (2 * x + width)/2, y, 1, height);
else
parent_class->draw_box(style, window, state_type, GTK_SHADOW_ETCHED_IN, area, NULL, NULL, x, (2 * y + height)/2, width, 1);
}
else {
if(xp_theme_draw(window, XP_THEME_ELEMENT_SCALE_TROUGH_H, style, x, (2 * y + height)/2, width, 2, state_type, area))
return;
parent_class->draw_box(style, window, state_type, GTK_SHADOW_ETCHED_IN, area, NULL, NULL, x, (2 * y + height)/2, width, 1);
}
return;
}
}
@ -1553,7 +1577,8 @@ draw_box (GtkStyle *style,
if (scrollbar->range.adjustment->page_size >= (scrollbar->range.adjustment->upper-scrollbar->range.adjustment->lower))
shadow_type = GTK_SHADOW_OUT;
}
else if (detail && strcmp (detail, "handlebox_bin") == 0)
else if (detail && (strcmp (detail, "handlebox_bin") == 0 || strcmp (detail, "toolbar") == 0 ||
strcmp (detail, "menubar") == 0))
{
if (xp_theme_draw(window, XP_THEME_ELEMENT_REBAR,
style, x, y, width, height, state_type, area))
@ -1561,6 +1586,10 @@ draw_box (GtkStyle *style,
return;
}
}
else if (detail &&
(!strcmp(detail, "handlebox"))) /* grip */
{
}
else
{
const gchar * name = gtk_widget_get_name (widget);
@ -1602,6 +1631,7 @@ draw_box (GtkStyle *style,
return;
}
}
}
@ -1698,26 +1728,28 @@ draw_extension(GtkStyle *style,
{
GtkNotebook *notebook = GTK_NOTEBOOK(widget);
GtkPositionType pos_type = gtk_notebook_get_tab_pos(notebook);
gint x2, y2, w2, h2;
if (pos_type == GTK_POS_TOP && state_type == GTK_STATE_NORMAL)
height += XP_EDGE_SIZE;
x2 = x; y2 = y; w2 = width; h2 = height;
if (pos_type == GTK_POS_TOP && state_type == GTK_STATE_NORMAL) {
/*h2 += XP_EDGE_SIZE;*/
}
else if (pos_type == GTK_POS_BOTTOM && state_type == GTK_STATE_NORMAL) {
/*h2 += XP_EDGE_SIZE;*/
}
else if (pos_type == GTK_POS_LEFT && state_type == GTK_STATE_NORMAL) {
x2 += 1;
w2 -= XP_EDGE_SIZE;
}
else if (pos_type == GTK_POS_RIGHT && state_type == GTK_STATE_NORMAL) {
w2 -= (XP_EDGE_SIZE + 1);
}
#if 0
/* FIXME: pos != TOP to be implemented */
else if (pos_type == GTK_POS_BOTTOM)
y -= XP_EDGE_SIZE;
else if (pos_type == GTK_POS_RIGHT)
width += XP_EDGE_SIZE;
else if (pos_type == GTK_POS_LEFT)
height -= XP_EDGE_SIZE;
#endif
if (pos_type == GTK_POS_TOP
&& xp_theme_draw
if (xp_theme_draw
(window, gtk_notebook_get_current_page(notebook)==0
? XP_THEME_ELEMENT_TAB_ITEM_LEFT_EDGE
: XP_THEME_ELEMENT_TAB_ITEM,
style, x, y, width, height, state_type, area))
style, x2, y2, w2, h2, state_type, area))
{
return;
}
@ -1805,13 +1837,22 @@ draw_hline (GtkStyle *style,
gint x2,
gint y)
{
#if 0
if (detail && !strcmp(detail, "menuitem")) {
if (xp_theme_draw(window, XP_THEME_ELEMENT_MENU_SEPARATOR, style,
x1, y, x2, style->ythickness, state_type, area)) {
return;
}
} else if (detail && !strcmp(detail, "toolbar")) {
if (xp_theme_draw(window, XP_THEME_ELEMENT_TOOLBAR_SEPARATOR_H, style,
x1, y, x2, style->ythickness, state_type, area)) {
return;
}
}
if(xp_theme_draw(window, XP_THEME_ELEMENT_LINE_H, style, x1, y, x2, style->ythickness, state_type, area))
return;
#endif
parent_class->draw_hline (style, window, state_type, area, widget,
detail, x1, x2, y);
@ -1828,10 +1869,45 @@ draw_vline (GtkStyle *style,
gint y2,
gint x)
{
#if 0
if (detail && !strcmp(detail, "toolbar")) {
if (xp_theme_draw(window, XP_THEME_ELEMENT_TOOLBAR_SEPARATOR_V, style,
x, y1, style->xthickness, y2, state_type, area)) {
return;
}
}
if(xp_theme_draw(window, XP_THEME_ELEMENT_LINE_V, style, x, y1, style->xthickness, y2, state_type, area))
return;
#endif
parent_class->draw_vline (style, window, state_type, area, widget,
detail, y1, y2, x);
}
static void
draw_slider (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
GtkShadowType shadow_type,
GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
gint x,
gint y,
gint width,
gint height,
GtkOrientation orientation)
{
if(GTK_IS_SCALE(widget) &&
xp_theme_draw(window, ((orientation == GTK_ORIENTATION_VERTICAL) ? XP_THEME_ELEMENT_SCALE_SLIDER_V : XP_THEME_ELEMENT_SCALE_SLIDER_H), style, x, y, width, height, state_type, area)) {
return;
}
parent_class->draw_slider (style, window, state_type, shadow_type, area, widget,
detail, x, y, width, height, orientation);
}
static void
draw_resize_grip (GtkStyle *style,
GdkWindow *window,
@ -1846,12 +1922,9 @@ draw_resize_grip (GtkStyle *style,
gint height)
{
if (detail && !strcmp(detail, "statusbar")) {
#if 0
/* DAL: TODO: find out why this regressed */
if (xp_theme_draw(window, XP_THEME_ELEMENT_STATUS_GRIPPER, style, x, y, width, height,
state_type, area))
return;
#endif
}
parent_class->draw_resize_grip (style, window, state_type, area,
@ -1888,63 +1961,51 @@ draw_handle (GtkStyle *style,
{
return;
}
/* grippers are just flat boxes when they're not a toolbar */
parent_class->draw_box (style, window, state_type, shadow_type,
area, widget, detail, x, y, width, height);
}
else if (!GTK_IS_PANED (widget))
{
/* TODO: Draw handle boxes as double lines: || */
parent_class->draw_handle (style, window, state_type, shadow_type,
area, widget, detail, x, y, width, height,
orientation);
}
}
static GdkPixbuf *
render_icon (GtkStyle *style,
const GtkIconSource *source,
GtkTextDirection direction,
GtkStateType state,
GtkIconSize size,
GtkWidget *widget,
const gchar *detail)
{
if (gtk_icon_source_get_state_wildcarded (source) && state == GTK_STATE_INSENSITIVE)
{
GdkPixbuf *normal, *insensitive;
int i, j, w, h, rs;
guchar *pixels, *row;
if (!GTK_IS_PANED(widget)) {
gint xthick, ythick;
GdkGC *light_gc, *dark_gc, *shadow_gc;
GdkRectangle dest;
normal = parent_class->render_icon (style, source, direction,
GTK_STATE_NORMAL, size,
widget, detail);
/* copy and add alpha channel at the same time */
insensitive = gdk_pixbuf_add_alpha (normal, FALSE, 0, 0, 0);
g_object_unref (normal);
/* remove all colour */
gdk_pixbuf_saturate_and_pixelate (insensitive, insensitive, 0.0, FALSE);
/* make partially transparent */
w = gdk_pixbuf_get_width (insensitive);
h = gdk_pixbuf_get_height (insensitive);
rs = gdk_pixbuf_get_rowstride (insensitive);
pixels = gdk_pixbuf_get_pixels (insensitive);
for (j=0; j<h; j++)
sanitize_size (window, &width, &height);
gtk_paint_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];
shadow_gc = style->mid_gc[state_type];
xthick = style->xthickness;
ythick = style->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);
gdk_gc_set_clip_rectangle(shadow_gc, &dest);
if (dest.width < dest.height)
{
row = pixels + j * rs;
for (i=0; i<w; i++)
{
row[i*4 + 3] = (guchar)(row[i*4 + 3] * 0.6);
}
}
return insensitive;
gdk_draw_line(window, light_gc, dest.x, dest.y, dest.x, dest.height);
gdk_draw_line(window, dark_gc, dest.x + (dest.width / 2), dest.y, dest.x + (dest.width / 2), dest.height);
gdk_draw_line(window, shadow_gc, dest.x + dest.width, dest.y, dest.x + dest.width, dest.height);
}
else
{
return parent_class->render_icon (style, source, direction,
state, size,
widget, detail);
gdk_draw_line(window, light_gc, dest.x, dest.y, dest.x + dest.width, dest.y);
gdk_draw_line(window, dark_gc, dest.x, dest.y + (dest.height / 2), dest.x + dest.width, dest.y + (dest.height / 2));
gdk_draw_line(window, shadow_gc, dest.x, dest.y + dest.height, dest.x + dest.width, dest.y + dest.height);
}
gdk_gc_set_clip_rectangle(shadow_gc, NULL);
gdk_gc_set_clip_rectangle(light_gc, NULL);
gdk_gc_set_clip_rectangle(dark_gc, NULL);
}
}
@ -1979,7 +2040,7 @@ msw_style_class_init (MswStyleClass *klass)
style_class->draw_vline = draw_vline;
style_class->draw_handle = draw_handle;
style_class->draw_resize_grip = draw_resize_grip;
style_class->render_icon = render_icon;
style_class->draw_slider = draw_slider;
}
GType msw_type_style = 0;

View File

@ -51,6 +51,35 @@
#define TMT_MSGBOXFONT 805
#endif
#define GP_LINEHORZ 2
#define GP_LINEVERT 3
#define TP_SEPARATOR 5
#define TP_SEPARATORVERT 6
/* GLOBALS LINEHORZ states */
#define LHS_FLAT 1
#define LHS_RAISED 2
#define LHS_SUNKEN 3
/* GLOBAL LINEVERT states */
#define LVS_FLAT 1
#define LVS_RAISED 2
#define LVS_SUNKEN 3
/* TRACKBAR parts */
#define TKP_TRACK 1
#define TKP_TRACKVERT 2
#define TKP_THUMB 3
#define TKP_THUMBBOTTOM 4
#define TKP_THUMBTOP 5
#define TKP_THUMBVERT 6
#define TKP_THUMBLEFT 7
#define TKP_THUMBRIGHT 8
#define TKP_TICS 9
#define TKP_TICSVERT 10
#define TRS_NORMAL 1
static const LPCWSTR class_descriptors[] =
{
L"Scrollbar", /* XP_THEME_CLASS_SCROLLBAR */
@ -68,7 +97,8 @@ static const LPCWSTR class_descriptors[] =
L"Globals", /* XP_THEME_CLASS_GLOBALS */
L"Menu", /* XP_THEME_CLASS_MENU */
L"Window", /* XP_THEME_CLASS_WINDOW */
L"Status" /* XP_THEME_CLASS_STATUS */
L"Status", /* XP_THEME_CLASS_STATUS */
L"Trackbar" /* XP_THEME_CLASS_TRACKBAR */
};
static const short element_part_map[]=
@ -105,7 +135,7 @@ static const short element_part_map[]=
PP_BAR,
PP_BARVERT,
TTP_STANDARD,
RP_BAND,
0 /*RP_BAND*/,
RP_GRIPPER,
RP_GRIPPERVERT,
RP_CHEVRON,
@ -113,7 +143,17 @@ static const short element_part_map[]=
MP_MENUITEM,
MP_SEPARATOR,
SP_GRIPPER,
SP_PANE
SP_PANE,
GP_LINEHORZ,
GP_LINEVERT,
TP_SEPARATOR,
TP_SEPARATORVERT,
TKP_TRACK,
TKP_TRACKVERT,
TKP_THUMB,
TKP_THUMBVERT,
TKP_TICS,
TKP_TICSVERT
};
static HINSTANCE uxtheme_dll = NULL;
@ -172,9 +212,8 @@ xp_theme_init (void)
memset(open_themes, 0, sizeof(open_themes));
uxtheme_dll = LoadLibrary("uxtheme.dll");
if (!uxtheme_dll) {
if (!uxtheme_dll)
return;
}
is_app_themed_func = (IsAppThemedFunc) GetProcAddress(uxtheme_dll, "IsAppThemed");
@ -251,12 +290,23 @@ xp_theme_get_handle_by_element (XpThemeElement element)
klazz = XP_THEME_CLASS_REBAR;
break;
case XP_THEME_ELEMENT_SCALE_TROUGH_H:
case XP_THEME_ELEMENT_SCALE_TROUGH_V:
case XP_THEME_ELEMENT_SCALE_SLIDER_H:
case XP_THEME_ELEMENT_SCALE_SLIDER_V:
case XP_THEME_ELEMENT_SCALE_TICS_H:
case XP_THEME_ELEMENT_SCALE_TICS_V:
klazz = XP_THEME_CLASS_TRACKBAR;
break;
case XP_THEME_ELEMENT_STATUS_GRIPPER:
case XP_THEME_ELEMENT_STATUS_PANE:
klazz = XP_THEME_CLASS_STATUS;
break;
case XP_THEME_ELEMENT_TOOLBAR_BUTTON:
case XP_THEME_ELEMENT_TOOLBAR_SEPARATOR_H:
case XP_THEME_ELEMENT_TOOLBAR_SEPARATOR_V:
klazz = XP_THEME_CLASS_TOOLBAR;
break;
@ -323,6 +373,11 @@ xp_theme_get_handle_by_element (XpThemeElement element)
klazz = XP_THEME_CLASS_TREEVIEW;
break;
case XP_THEME_ELEMENT_LINE_H:
case XP_THEME_ELEMENT_LINE_V:
klazz = XP_THEME_CLASS_GLOBALS;
break;
default:
break;
}
@ -351,7 +406,7 @@ xp_theme_map_gtk_state (XpThemeElement element, GtkStateType state)
case XP_THEME_ELEMENT_REBAR_GRIPPER_H:
case XP_THEME_ELEMENT_REBAR_GRIPPER_V:
ret = CHEVS_NORMAL;
ret = 0;
break;
case XP_THEME_ELEMENT_STATUS_GRIPPER:
@ -374,6 +429,11 @@ xp_theme_map_gtk_state (XpThemeElement element, GtkStateType state)
}
break;
case XP_THEME_ELEMENT_TOOLBAR_SEPARATOR_H:
case XP_THEME_ELEMENT_TOOLBAR_SEPARATOR_V:
ret = TS_NORMAL;
break;
case XP_THEME_ELEMENT_TOOLBAR_BUTTON:
switch (state)
{
@ -430,10 +490,13 @@ xp_theme_map_gtk_state (XpThemeElement element, GtkStateType state)
}
break;
case XP_THEME_ELEMENT_SCROLLBAR_H:
case XP_THEME_ELEMENT_SCROLLBAR_V:
case XP_THEME_ELEMENT_TROUGH_H:
case XP_THEME_ELEMENT_TROUGH_V:
ret = SCRBS_NORMAL;
break;
case XP_THEME_ELEMENT_SCROLLBAR_H:
case XP_THEME_ELEMENT_SCROLLBAR_V:
switch(state)
{
case GTK_STATE_SELECTED:
@ -635,6 +698,27 @@ xp_theme_map_gtk_state (XpThemeElement element, GtkStateType state)
}
break;
case XP_THEME_ELEMENT_LINE_H:
switch(state) {
/* LHS_FLAT, LHS_RAISED, LHS_SUNKEN */
ret = LHS_RAISED;
break;
}
break;
case XP_THEME_ELEMENT_LINE_V:
switch(state) {
/* LVS_FLAT, LVS_RAISED, LVS_SUNKEN */
ret = LVS_RAISED;
break;
}
break;
case XP_THEME_ELEMENT_SCALE_TROUGH_H:
case XP_THEME_ELEMENT_SCALE_TROUGH_V:
ret = TRS_NORMAL;
break;
default:
switch(state)
{
@ -713,34 +797,13 @@ xp_theme_draw (GdkWindow *win, XpThemeElement element, GtkStyle *style,
part_state = xp_theme_map_gtk_state(element, state_type);
#ifdef GNATS_HACK
if (element == XP_THEME_ELEMENT_REBAR_GRIPPER_V
|| element == XP_THEME_ELEMENT_REBAR_GRIPPER_H)
{
/* Hack alert: when XP draws a gripper, it does not seem to fill
up the whole rectangle. It only fills the gripper line
itself. Therefore we manually fill up the background here
ourselves. I still have to look into this a bit further, as
tests with GNAT Programming System show some awkward
interference between this FillRect and the subsequent
DrawThemeBackground(). */
FillRect (dc, &rect, (HBRUSH) (COLOR_3DFACE+1));
}
#endif
if (is_theme_partially_transparent_func && draw_theme_parent_background_func &&
is_theme_partially_transparent_func(theme, element_part_map[element], part_state))
{
draw_theme_parent_background_func(GDK_WINDOW_HWND(win), dc, pClip);
}
draw_theme_background_func(theme, dc, element_part_map[element], part_state, &rect, pClip);
gdk_win32_hdc_release(drawable, style->dark_gc[state_type], 0);
return TRUE;
}
static gboolean
gboolean
xp_theme_is_active (void)
{
gboolean active = FALSE;
@ -768,13 +831,13 @@ xp_theme_is_drawable (XpThemeElement element)
}
gboolean
xp_theme_get_system_font (XpThemeClass klazz, XpThemeFont fontId, LOGFONT *lf)
xp_theme_get_system_font (XpThemeClass klazz, XpThemeFont fontId, OUT LOGFONT *lf)
{
int themeFont;
if (get_theme_sys_font_func != NULL)
if (xp_theme_is_active () && get_theme_sys_font_func != NULL)
{
HTHEME theme = xp_theme_get_handle_by_class(klazz);
int themeFont;
if (!theme)
return FALSE;
@ -797,9 +860,9 @@ xp_theme_get_system_font (XpThemeClass klazz, XpThemeFont fontId, LOGFONT *lf)
}
gboolean
xp_theme_get_system_color (XpThemeClass klazz, int colorId, DWORD * pColor)
xp_theme_get_system_color (XpThemeClass klazz, int colorId, OUT DWORD * pColor)
{
if (get_theme_sys_color_func != NULL)
if (xp_theme_is_active () && get_theme_sys_color_func != NULL)
{
HTHEME theme = xp_theme_get_handle_by_class(klazz);
@ -811,9 +874,9 @@ xp_theme_get_system_color (XpThemeClass klazz, int colorId, DWORD * pColor)
}
gboolean
xp_theme_get_system_metric (XpThemeClass klazz, int metricId, int * pVal)
xp_theme_get_system_metric (XpThemeClass klazz, int metricId, OUT int * pVal)
{
if (get_theme_sys_metric_func != NULL)
if (xp_theme_is_active () && get_theme_sys_metric_func != NULL)
{
HTHEME theme = xp_theme_get_handle_by_class(klazz);

View File

@ -43,6 +43,7 @@ typedef enum
XP_THEME_CLASS_MENU,
XP_THEME_CLASS_WINDOW,
XP_THEME_CLASS_STATUS,
XP_THEME_CLASS_TRACKBAR,
XP_THEME_CLASS__SIZEOF
} XpThemeClass;
@ -89,6 +90,16 @@ typedef enum
XP_THEME_ELEMENT_MENU_SEPARATOR,
XP_THEME_ELEMENT_STATUS_GRIPPER,
XP_THEME_ELEMENT_STATUS_PANE,
XP_THEME_ELEMENT_LINE_H,
XP_THEME_ELEMENT_LINE_V,
XP_THEME_ELEMENT_TOOLBAR_SEPARATOR_H,
XP_THEME_ELEMENT_TOOLBAR_SEPARATOR_V,
XP_THEME_ELEMENT_SCALE_TROUGH_H,
XP_THEME_ELEMENT_SCALE_TROUGH_V,
XP_THEME_ELEMENT_SCALE_SLIDER_H,
XP_THEME_ELEMENT_SCALE_SLIDER_V,
XP_THEME_ELEMENT_SCALE_TICS_H,
XP_THEME_ELEMENT_SCALE_TICS_V,
XP_THEME_ELEMENT__SIZEOF
} XpThemeElement;
@ -108,8 +119,10 @@ gboolean xp_theme_draw (GdkWindow *win, XpThemeElement element,
int height, GtkStateType state_type,
GdkRectangle *area);
gboolean xp_theme_is_drawable (XpThemeElement element);
gboolean xp_theme_get_system_font (XpThemeClass klazz, XpThemeFont fontId, LOGFONT *lf);
gboolean xp_theme_get_system_color (XpThemeClass klazz, int colorId, DWORD * pColor);
gboolean xp_theme_get_system_metric (XpThemeClass klazz, int metricId, int * pVal);
gboolean xp_theme_get_system_font (XpThemeClass klazz, XpThemeFont fontId, OUT LOGFONT *lf);
gboolean xp_theme_get_system_color (XpThemeClass klazz, int colorId, OUT DWORD * pColor);
gboolean xp_theme_get_system_metric (XpThemeClass klazz, int metricId, OUT int * pVal);
gboolean xp_theme_is_active (void);
#endif /* XP_THEME_H */

View File

@ -48,8 +48,10 @@ typedef HANDLE HTHEME;
#define SBP_ARROWBTN 1
#define SBP_THUMBBTNHORZ 2
#define SBP_THUMBBTNVERT 3
#define SBP_LOWERTRACKHORZ 5
#define SBP_LOWERTRACKHORZ 4
#define SBP_UPPERTRACKHORZ 5
#define SBP_LOWERTRACKVERT 6
#define SBP_UPPERTRACKVERT 7
#define SBP_GRIPPERHORZ 8
#define SBP_GRIPPERVERT 9
@ -151,7 +153,7 @@ typedef HANDLE HTHEME;
#define MS_SELECTED 2
#define MS_DEMOTED 3
#define SP_PANE 1
#define SP_GRIPPER 2
#define SP_PANE 2
#define SP_GRIPPER 3
#endif /* XP_THEME_DFNS_H */