forked from AuroraMiddleware/gtk
use more XP style functions
This commit is contained in:
parent
806d18a4ae
commit
28087cb57d
@ -1,3 +1,13 @@
|
||||
2003-10-21 Dom Lachowicz <cinamod@hotmail.com>
|
||||
|
||||
* src/wimp_style.c: Use theme colors
|
||||
Use theme metrics
|
||||
(disabled) Use theme fonts
|
||||
Theme menu items, menu separators
|
||||
Draw status bar resize grips
|
||||
|
||||
* src/xp_theme.c: Ditto
|
||||
|
||||
2003-10-20 Raymond Penners <raymond@dotsphinx.com>
|
||||
|
||||
* src/wimp_style.c: Added grippers to XP scrollbars.
|
||||
|
@ -116,40 +116,39 @@ static struct {
|
||||
{ radio_text_bits, NULL }
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CAPTION_FONT,
|
||||
MENU_FONT,
|
||||
STATUS_FONT,
|
||||
MESSAGE_FONT
|
||||
} SystemFontType;
|
||||
|
||||
static gboolean
|
||||
get_system_font(SystemFontType type, LOGFONT *out_lf)
|
||||
get_system_font(XpThemeClass klazz, XpThemeFont type, LOGFONT *out_lf)
|
||||
{
|
||||
NONCLIENTMETRICS ncm;
|
||||
ncm.cbSize = sizeof(NONCLIENTMETRICS);
|
||||
#if 0
|
||||
/* TODO: this crashes. need to figure out why and how to fix it */
|
||||
if (xp_theme_get_system_font(klazz, type, out_lf)) {
|
||||
return TRUE;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
NONCLIENTMETRICS ncm;
|
||||
ncm.cbSize = sizeof(NONCLIENTMETRICS);
|
||||
|
||||
if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
|
||||
sizeof(NONCLIENTMETRICS), &ncm, 0))
|
||||
{
|
||||
if (type == CAPTION_FONT)
|
||||
*out_lf = ncm.lfCaptionFont;
|
||||
else if (type == MENU_FONT)
|
||||
*out_lf = ncm.lfMenuFont;
|
||||
else if (type == STATUS_FONT)
|
||||
*out_lf = ncm.lfStatusFont;
|
||||
else
|
||||
*out_lf = ncm.lfMessageFont;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
|
||||
sizeof(NONCLIENTMETRICS), &ncm, 0))
|
||||
{
|
||||
if (type == XP_THEME_FONT_CAPTION)
|
||||
*out_lf = ncm.lfCaptionFont;
|
||||
else if (type == XP_THEME_FONT_MENU)
|
||||
*out_lf = ncm.lfMenuFont;
|
||||
else if (type == XP_THEME_FONT_STATUS)
|
||||
*out_lf = ncm.lfStatusFont;
|
||||
else
|
||||
*out_lf = ncm.lfMessageFont;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static char *
|
||||
sys_font_to_pango_font (SystemFontType type, char * buf)
|
||||
sys_font_to_pango_font (XpThemeClass klazz, XpThemeFont type, char * buf)
|
||||
{
|
||||
HDC hDC;
|
||||
HWND hwnd;
|
||||
@ -158,7 +157,7 @@ sys_font_to_pango_font (SystemFontType type, char * buf)
|
||||
const char * weight;
|
||||
const char * style;
|
||||
|
||||
if (get_system_font(type, &lf))
|
||||
if (get_system_font(klazz, type, &lf))
|
||||
{
|
||||
switch (lf.lfWeight) {
|
||||
case FW_THIN:
|
||||
@ -218,33 +217,35 @@ sys_font_to_pango_font (SystemFontType type, char * buf)
|
||||
#define SPI_GETMENUSHOWDELAY 106
|
||||
#endif
|
||||
|
||||
#define XP_THEME_CLASS_UNKNOWN XP_THEME_CLASS_BUTTON
|
||||
|
||||
static void
|
||||
setup_menu_settings (void)
|
||||
{
|
||||
int menu_delay;
|
||||
gboolean win95 = FALSE;
|
||||
|
||||
|
||||
GtkSettings * settings;
|
||||
OSVERSIONINFOEX osvi;
|
||||
|
||||
|
||||
settings = gtk_settings_get_default ();
|
||||
if (!settings)
|
||||
return;
|
||||
|
||||
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||
|
||||
|
||||
if (!GetVersionEx ( (OSVERSIONINFO *) &osvi))
|
||||
win95 = TRUE; /* assume the worst */
|
||||
|
||||
|
||||
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
|
||||
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
|
||||
win95 = TRUE;
|
||||
|
||||
|
||||
if (!win95) {
|
||||
if (SystemParametersInfo (SPI_GETMENUSHOWDELAY, 0, &menu_delay, 0)) {
|
||||
GObjectClass * klazz = G_OBJECT_GET_CLASS(G_OBJECT(settings));
|
||||
|
||||
|
||||
if (klazz) {
|
||||
if (g_object_class_find_property (klazz, "gtk-menu-bar-popup-delay")) {
|
||||
g_object_set (G_OBJECT (settings), "gtk-menu-bar-popup-delay",
|
||||
@ -286,8 +287,7 @@ wimp_style_setup_system_settings (void)
|
||||
g_object_set (G_OBJECT (settings), "gtk-double-click-time",
|
||||
GetDoubleClickTime(), NULL);
|
||||
g_object_set (G_OBJECT (settings), "gtk-dnd-drag-threshold",
|
||||
GetSystemMetrics (SM_CXDRAG), NULL);
|
||||
|
||||
GetSystemMetrics(SM_CXDRAG), NULL);
|
||||
|
||||
setup_menu_settings ();
|
||||
|
||||
@ -298,7 +298,6 @@ wimp_style_setup_system_settings (void)
|
||||
|
||||
g_object_set (G_OBJECT (settings), "gtk-icon-sizes",
|
||||
"gtk-menu=10,10 : gtk-button=16,16 : gtk-small-toolbar=16,16 : gtk-large-toolbar=16,16 : gtk-dialog=32,32 : gtk-dnd=32,32", NULL);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -313,20 +312,35 @@ setup_system_font(GtkStyle *style)
|
||||
{
|
||||
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(XP_THEME_CLASS_UNKNOWN, XP_THEME_FONT_MESSAGE, buf)) != NULL)
|
||||
style->font_desc = pango_font_description_from_string(font);
|
||||
}
|
||||
|
||||
static void
|
||||
sys_color_to_gtk_color(int id, GdkColor *pcolor)
|
||||
sys_color_to_gtk_color(XpThemeClass klazz, int id, GdkColor *pcolor)
|
||||
{
|
||||
DWORD color = GetSysColor(id);
|
||||
DWORD color;
|
||||
|
||||
if (!xp_theme_get_system_color (klazz, id, &color))
|
||||
color = GetSysColor(id);
|
||||
|
||||
pcolor->pixel = color;
|
||||
pcolor->red = (GetRValue(color) << 8) | GetRValue(color);
|
||||
pcolor->green = (GetGValue(color) << 8) | GetGValue(color);
|
||||
pcolor->blue = (GetBValue(color) << 8) | GetBValue(color);
|
||||
}
|
||||
|
||||
static int
|
||||
get_system_metric(XpThemeClass klazz, int id)
|
||||
{
|
||||
int rval;
|
||||
|
||||
if (!xp_theme_get_system_metric(klazz, id, &rval))
|
||||
rval = GetSystemMetrics (id);
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
static void
|
||||
setup_wimp_rc_style(void)
|
||||
{
|
||||
@ -351,26 +365,26 @@ setup_wimp_rc_style(void)
|
||||
gint paned_size = 15;
|
||||
|
||||
/* Prelight */
|
||||
sys_color_to_gtk_color(COLOR_HIGHLIGHTTEXT, &fg_prelight);
|
||||
sys_color_to_gtk_color(COLOR_HIGHLIGHT, &bg_prelight);
|
||||
sys_color_to_gtk_color(COLOR_HIGHLIGHT, &base_prelight);
|
||||
sys_color_to_gtk_color(COLOR_HIGHLIGHTTEXT, &text_prelight);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_UNKNOWN, COLOR_HIGHLIGHTTEXT, &fg_prelight);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_UNKNOWN, COLOR_HIGHLIGHT, &bg_prelight);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_UNKNOWN, COLOR_HIGHLIGHT, &base_prelight);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_UNKNOWN, COLOR_HIGHLIGHTTEXT, &text_prelight);
|
||||
|
||||
sys_color_to_gtk_color(COLOR_MENUTEXT, &menu_text_color);
|
||||
sys_color_to_gtk_color(COLOR_MENU, &menu_color);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_MENU, COLOR_MENUTEXT, &menu_text_color);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_MENU, COLOR_MENU, &menu_color);
|
||||
|
||||
/* tooltips */
|
||||
sys_color_to_gtk_color(COLOR_INFOTEXT, &tooltip_fore);
|
||||
sys_color_to_gtk_color(COLOR_INFOBK, &tooltip_back);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_TOOLTIP, COLOR_INFOTEXT, &tooltip_fore);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_TOOLTIP, COLOR_INFOBK, &tooltip_back);
|
||||
|
||||
/* text on push buttons. TODO: button shadows, backgrounds, and highlights */
|
||||
sys_color_to_gtk_color(COLOR_BTNTEXT, &btn_fore);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_BTNTEXT, &btn_fore);
|
||||
|
||||
/* progress bar background color */
|
||||
sys_color_to_gtk_color(COLOR_HIGHLIGHT, &progress_back);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_PROGRESS, COLOR_HIGHLIGHT, &progress_back);
|
||||
|
||||
/* Enable coloring for menus. */
|
||||
font_ptr = sys_font_to_pango_font (MENU_FONT,font_buf);
|
||||
font_ptr = sys_font_to_pango_font (XP_THEME_CLASS_MENU, XP_THEME_FONT_MENU,font_buf);
|
||||
sprintf(buf, "style \"wimp-menu\" = \"wimp-default\"\n"
|
||||
"{fg[PRELIGHT] = { %d, %d, %d }\n"
|
||||
"bg[PRELIGHT] = { %d, %d, %d }\n"
|
||||
@ -403,7 +417,7 @@ setup_wimp_rc_style(void)
|
||||
gtk_rc_parse_string(buf);
|
||||
|
||||
/* enable tooltip fonts */
|
||||
font_ptr = sys_font_to_pango_font (STATUS_FONT,font_buf);
|
||||
font_ptr = sys_font_to_pango_font (XP_THEME_CLASS_STATUS, XP_THEME_FONT_STATUS,font_buf);
|
||||
sprintf(buf, "style \"wimp-tooltips-caption\" = \"wimp-default\"\n"
|
||||
"{fg[NORMAL] = { %d, %d, %d }\n"
|
||||
"%s = \"%s\"\n"
|
||||
@ -424,7 +438,7 @@ setup_wimp_rc_style(void)
|
||||
gtk_rc_parse_string(buf);
|
||||
|
||||
/* enable font theming for status bars */
|
||||
font_ptr = sys_font_to_pango_font (STATUS_FONT,font_buf);
|
||||
font_ptr = sys_font_to_pango_font (XP_THEME_CLASS_STATUS, XP_THEME_FONT_STATUS,font_buf);
|
||||
sprintf(buf, "style \"wimp-statusbar\" = \"wimp-default\"\n"
|
||||
"{%s = \"%s\"\n"
|
||||
"}widget_class \"*GtkStatusbar*\" style \"wimp-statusbar\"\n",
|
||||
@ -463,7 +477,7 @@ setup_wimp_rc_style(void)
|
||||
"GtkRange::trough_border = 0\n"
|
||||
"}widget_class \"*GtkVScrollbar*\" style \"wimp-vscrollbar\"\n",
|
||||
GetSystemMetrics(SM_CYVTHUMB),
|
||||
GetSystemMetrics(SM_CXVSCROLL));
|
||||
get_system_metric(XP_THEME_CLASS_SCROLLBAR, SM_CXVSCROLL));
|
||||
gtk_rc_parse_string(buf);
|
||||
|
||||
sprintf(buf, "style \"wimp-hscrollbar\" = \"wimp-default\"\n"
|
||||
@ -473,7 +487,7 @@ setup_wimp_rc_style(void)
|
||||
"GtkRange::trough_border = 0\n"
|
||||
"}widget_class \"*GtkHScrollbar*\" style \"wimp-hscrollbar\"\n",
|
||||
GetSystemMetrics(SM_CXHTHUMB),
|
||||
GetSystemMetrics(SM_CYHSCROLL));
|
||||
get_system_metric(XP_THEME_CLASS_SCROLLBAR, SM_CYHSCROLL));
|
||||
gtk_rc_parse_string(buf);
|
||||
|
||||
/* radio/check button sizes */
|
||||
@ -498,37 +512,37 @@ setup_system_styles(GtkStyle *style)
|
||||
int i;
|
||||
|
||||
/* Default forgeground */
|
||||
sys_color_to_gtk_color(COLOR_WINDOWTEXT, &style->fg[GTK_STATE_NORMAL]);
|
||||
sys_color_to_gtk_color(COLOR_WINDOWTEXT, &style->fg[GTK_STATE_ACTIVE]);
|
||||
sys_color_to_gtk_color(COLOR_WINDOWTEXT, &style->fg[GTK_STATE_PRELIGHT]);
|
||||
sys_color_to_gtk_color(COLOR_HIGHLIGHTTEXT, &style->fg[GTK_STATE_SELECTED]);
|
||||
sys_color_to_gtk_color(COLOR_GRAYTEXT, &style->fg[GTK_STATE_INSENSITIVE]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_WINDOW, COLOR_WINDOWTEXT, &style->fg[GTK_STATE_NORMAL]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_WINDOW, COLOR_WINDOWTEXT, &style->fg[GTK_STATE_ACTIVE]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_WINDOW, COLOR_WINDOWTEXT, &style->fg[GTK_STATE_PRELIGHT]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_UNKNOWN, COLOR_HIGHLIGHTTEXT, &style->fg[GTK_STATE_SELECTED]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_UNKNOWN, COLOR_GRAYTEXT, &style->fg[GTK_STATE_INSENSITIVE]);
|
||||
|
||||
/* Default background */
|
||||
sys_color_to_gtk_color(COLOR_3DFACE, &style->bg[GTK_STATE_NORMAL]);
|
||||
sys_color_to_gtk_color(COLOR_SCROLLBAR, &style->bg[GTK_STATE_ACTIVE]);
|
||||
sys_color_to_gtk_color(COLOR_3DFACE, &style->bg[GTK_STATE_PRELIGHT]);
|
||||
sys_color_to_gtk_color(COLOR_HIGHLIGHT, &style->bg[GTK_STATE_SELECTED]);
|
||||
sys_color_to_gtk_color(COLOR_3DFACE, &style->bg[GTK_STATE_INSENSITIVE]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_3DFACE, &style->bg[GTK_STATE_NORMAL]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_SCROLLBAR, COLOR_SCROLLBAR, &style->bg[GTK_STATE_ACTIVE]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_3DFACE, &style->bg[GTK_STATE_PRELIGHT]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_UNKNOWN, COLOR_HIGHLIGHT, &style->bg[GTK_STATE_SELECTED]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_3DFACE, &style->bg[GTK_STATE_INSENSITIVE]);
|
||||
|
||||
/* Default base */
|
||||
sys_color_to_gtk_color(COLOR_WINDOW, &style->base[GTK_STATE_NORMAL]);
|
||||
sys_color_to_gtk_color(COLOR_HIGHLIGHT, &style->base[GTK_STATE_ACTIVE]);
|
||||
sys_color_to_gtk_color(COLOR_WINDOW, &style->base[GTK_STATE_PRELIGHT]);
|
||||
sys_color_to_gtk_color(COLOR_HIGHLIGHT, &style->base[GTK_STATE_SELECTED]);
|
||||
sys_color_to_gtk_color(COLOR_3DFACE, &style->base[GTK_STATE_INSENSITIVE]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_WINDOW, COLOR_WINDOW, &style->base[GTK_STATE_NORMAL]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_UNKNOWN, COLOR_HIGHLIGHT, &style->base[GTK_STATE_ACTIVE]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_WINDOW, COLOR_WINDOW, &style->base[GTK_STATE_PRELIGHT]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_UNKNOWN, COLOR_HIGHLIGHT, &style->base[GTK_STATE_SELECTED]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_3DFACE, &style->base[GTK_STATE_INSENSITIVE]);
|
||||
|
||||
/* Default text */
|
||||
sys_color_to_gtk_color(COLOR_WINDOWTEXT, &style->text[GTK_STATE_NORMAL]);
|
||||
sys_color_to_gtk_color(COLOR_HIGHLIGHTTEXT, &style->text[GTK_STATE_ACTIVE]);
|
||||
sys_color_to_gtk_color(COLOR_WINDOWTEXT, &style->text[GTK_STATE_PRELIGHT]);
|
||||
sys_color_to_gtk_color(COLOR_HIGHLIGHTTEXT, &style->text[GTK_STATE_SELECTED]);
|
||||
sys_color_to_gtk_color(COLOR_GRAYTEXT, &style->text[GTK_STATE_INSENSITIVE]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_WINDOW, COLOR_WINDOWTEXT, &style->text[GTK_STATE_NORMAL]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_UNKNOWN, COLOR_HIGHLIGHTTEXT, &style->text[GTK_STATE_ACTIVE]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_WINDOW, COLOR_WINDOWTEXT, &style->text[GTK_STATE_PRELIGHT]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_UNKNOWN, COLOR_HIGHLIGHTTEXT, &style->text[GTK_STATE_SELECTED]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_UNKNOWN, COLOR_GRAYTEXT, &style->text[GTK_STATE_INSENSITIVE]);
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
sys_color_to_gtk_color(COLOR_3DSHADOW, &style->dark[i]);
|
||||
sys_color_to_gtk_color(COLOR_3DHILIGHT, &style->light[i]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_3DSHADOW, &style->dark[i]);
|
||||
sys_color_to_gtk_color(XP_THEME_CLASS_BUTTON, COLOR_3DHILIGHT, &style->light[i]);
|
||||
|
||||
style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
|
||||
style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
|
||||
@ -1097,10 +1111,6 @@ draw_box (GtkStyle *style,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
const gchar * name;
|
||||
|
||||
name = gtk_widget_get_name (widget);
|
||||
|
||||
if (detail &&
|
||||
(!strcmp (detail, "button") ||
|
||||
!strcmp (detail, "buttondefault")))
|
||||
@ -1180,17 +1190,14 @@ draw_box (GtkStyle *style,
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (name && !strcmp (name, "gtk-tooltips")) {
|
||||
if (xp_theme_draw (window, XP_THEME_ELEMENT_TOOLTIP, style, x, y, width, height, state_type, area))
|
||||
else if (detail && strcmp (detail, "menuitem") == 0) {
|
||||
shadow_type = GTK_SHADOW_NONE;
|
||||
if (xp_theme_draw (window, XP_THEME_ELEMENT_MENUITEM, style, x, y, width, height, state_type, area))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (detail && strcmp (detail, "menuitem") == 0)
|
||||
shadow_type = GTK_SHADOW_NONE;
|
||||
|
||||
if (detail && !strcmp (detail, "trough"))
|
||||
else if (detail && !strcmp (detail, "trough"))
|
||||
{
|
||||
if (widget && GTK_IS_PROGRESS_BAR (widget))
|
||||
{
|
||||
@ -1262,6 +1269,17 @@ draw_box (GtkStyle *style,
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const gchar * name = gtk_widget_get_name (widget);
|
||||
|
||||
if (name && !strcmp (name, "gtk-tooltips")) {
|
||||
if (xp_theme_draw (window, XP_THEME_ELEMENT_TOOLTIP, style, x, y, width, height, state_type, area))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parent_class->draw_box (style, window, state_type, shadow_type, area,
|
||||
widget, detail, x, y, width, height);
|
||||
@ -1463,6 +1481,13 @@ draw_hline (GtkStyle *style,
|
||||
gint x2,
|
||||
gint y)
|
||||
{
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
#if UXTHEME_HAS_LINES
|
||||
if (xp_theme_draw(window, XP_THEME_ELEMENT_HLINE, style, x1, y, x2,
|
||||
style->ythickness, state_type, area))
|
||||
@ -1500,6 +1525,29 @@ draw_vline (GtkStyle *style,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_resize_grip (GtkStyle *style,
|
||||
GdkWindow *window,
|
||||
GtkStateType state_type,
|
||||
GdkRectangle *area,
|
||||
GtkWidget *widget,
|
||||
const gchar *detail,
|
||||
GdkWindowEdge edge,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
if (detail && !strcmp(detail, "statusbar")) {
|
||||
if (!xp_theme_draw(window, XP_THEME_ELEMENT_STATUS_GRIPPER, style, x, y, width, height,
|
||||
state_type, area))
|
||||
return;
|
||||
}
|
||||
|
||||
parent_class->draw_resize_grip (style, window, state_type, area,
|
||||
widget, detail, edge, x, y, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_handle (GtkStyle *style,
|
||||
GdkWindow *window,
|
||||
@ -1519,7 +1567,7 @@ draw_handle (GtkStyle *style,
|
||||
XpThemeElement hndl;
|
||||
|
||||
sanitize_size (window, &width, &height);
|
||||
|
||||
|
||||
if (orientation == GTK_ORIENTATION_VERTICAL)
|
||||
hndl = XP_THEME_ELEMENT_GRIPPER_V;
|
||||
else
|
||||
@ -1573,6 +1621,7 @@ wimp_style_class_init (WimpStyleClass *klass)
|
||||
style_class->draw_hline = draw_hline;
|
||||
style_class->draw_vline = draw_vline;
|
||||
style_class->draw_handle = draw_handle;
|
||||
style_class->draw_resize_grip = draw_resize_grip;
|
||||
}
|
||||
|
||||
GType wimp_type_style = 0;
|
||||
|
@ -36,19 +36,22 @@
|
||||
|
||||
static const LPCWSTR class_descriptors[] =
|
||||
{
|
||||
L"Scrollbar",
|
||||
L"Button",
|
||||
L"Header",
|
||||
L"ComboBox",
|
||||
L"Tab",
|
||||
L"Edit",
|
||||
L"TreeView",
|
||||
L"Spin",
|
||||
L"Progress",
|
||||
L"Tooltip",
|
||||
L"Rebar",
|
||||
L"Toolbar",
|
||||
L"Globals"
|
||||
L"Scrollbar", /* XP_THEME_CLASS_SCROLLBAR */
|
||||
L"Button", /* XP_THEME_CLASS_BUTTON */
|
||||
L"Header", /* XP_THEME_CLASS_HEADER */
|
||||
L"ComboBox", /* XP_THEME_CLASS_COMBOBOX */
|
||||
L"Tab", /* XP_THEME_CLASS_TAB */
|
||||
L"Edit", /* XP_THEME_CLASS_EDIT */
|
||||
L"TreeView", /* XP_THEME_CLASS_TREEVIEW */
|
||||
L"Spin", /* XP_THEME_CLASS_SPIN */
|
||||
L"Progress", /* XP_THEME_CLASS_PROGRESS */
|
||||
L"Tooltip", /* XP_THEME_CLASS_TOOLTIP */
|
||||
L"Rebar", /* XP_THEME_CLASS_REBAR */
|
||||
L"Toolbar", /* XP_THEME_CLASS_TOOLBAR */
|
||||
L"Globals", /* XP_THEME_CLASS_GLOBALS */
|
||||
L"Menu", /* XP_THEME_CLASS_MENU */
|
||||
L"Window", /* XP_THEME_CLASS_WINDOW */
|
||||
L"Status" /* XP_THEME_CLASS_STATUS */
|
||||
};
|
||||
|
||||
static const short element_part_map[]=
|
||||
@ -89,7 +92,11 @@ static const short element_part_map[]=
|
||||
RP_GRIPPER,
|
||||
RP_GRIPPERVERT,
|
||||
RP_CHEVRON,
|
||||
TP_BUTTON
|
||||
TP_BUTTON,
|
||||
MP_MENUITEM,
|
||||
MP_SEPARATOR,
|
||||
SP_GRIPPER,
|
||||
SP_PANE
|
||||
|
||||
#if UXTHEME_HAS_LINES
|
||||
,
|
||||
@ -102,7 +109,10 @@ static HINSTANCE uxtheme_dll = NULL;
|
||||
static HTHEME open_themes[XP_THEME_CLASS__SIZEOF];
|
||||
|
||||
typedef HRESULT (FAR PASCAL *GetThemeSysFontFunc)
|
||||
(HTHEME hTheme, int iFontID, FAR LOGFONT *plf);
|
||||
(HTHEME hTheme, int iFontID, OUT LOGFONT *plf);
|
||||
typedef int (FAR PASCAL *GetThemeSysSizeFunc)
|
||||
(HTHEME hTheme, int iSizeId);
|
||||
typedef COLORREF (FAR PASCAL *GetThemeSysColorFunc)(HTHEME hTheme, int iColorID);
|
||||
typedef HTHEME (FAR PASCAL *OpenThemeDataFunc)
|
||||
(HWND hwnd, LPCWSTR pszClassList);
|
||||
typedef HRESULT (FAR PASCAL *CloseThemeDataFunc)(HTHEME theme);
|
||||
@ -113,6 +123,8 @@ typedef HRESULT (FAR PASCAL *EnableThemeDialogTextureFunc)(HWND hwnd, DWORD dwFl
|
||||
typedef BOOL (FAR PASCAL *IsThemeActiveFunc)(VOID);
|
||||
|
||||
static GetThemeSysFontFunc get_theme_sys_font_func = NULL;
|
||||
static GetThemeSysColorFunc get_theme_sys_color_func = NULL;
|
||||
static GetThemeSysSizeFunc get_theme_sys_metric_func = NULL;
|
||||
static OpenThemeDataFunc open_theme_data_func = NULL;
|
||||
static CloseThemeDataFunc close_theme_data_func = NULL;
|
||||
static DrawThemeBackgroundFunc draw_theme_background_func = NULL;
|
||||
@ -125,7 +137,7 @@ static void
|
||||
xp_theme_close_open_handles (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i=0; i < XP_THEME_CLASS__SIZEOF; i++)
|
||||
{
|
||||
if (open_themes[i])
|
||||
@ -142,15 +154,22 @@ xp_theme_init (void)
|
||||
if (uxtheme_dll)
|
||||
return;
|
||||
|
||||
uxtheme_dll = LoadLibrary("uxtheme.dll");
|
||||
memset(open_themes, 0, sizeof(open_themes));
|
||||
|
||||
uxtheme_dll = LoadLibrary("uxtheme.dll");
|
||||
if (!uxtheme_dll) {
|
||||
was_theming_active = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
is_theme_active_func = (IsThemeActiveFunc) GetProcAddress(uxtheme_dll, "IsThemeActive");
|
||||
open_theme_data_func = (OpenThemeDataFunc) GetProcAddress(uxtheme_dll, "OpenThemeData");
|
||||
close_theme_data_func = (CloseThemeDataFunc) GetProcAddress(uxtheme_dll, "CloseThemeData");
|
||||
draw_theme_background_func = (DrawThemeBackgroundFunc) GetProcAddress(uxtheme_dll, "DrawThemeBackground");
|
||||
enable_theme_dialog_texture_func = (EnableThemeDialogTextureFunc) GetProcAddress(uxtheme_dll, "EnableThemeDialogTexture");
|
||||
get_theme_sys_font_func = (GetThemeSysFontFunc) GetProcAddress(uxtheme_dll, "GetThemeSysFont");
|
||||
get_theme_sys_color_func = (GetThemeSysColorFunc) GetProcAddress(uxtheme_dll, "GetThemeSysColor");
|
||||
get_theme_sys_metric_func = (GetThemeSysSizeFunc) GetProcAddress(uxtheme_dll, "GetThemeSysSize");
|
||||
|
||||
if (is_theme_active_func)
|
||||
{
|
||||
@ -183,6 +202,8 @@ xp_theme_exit (void)
|
||||
draw_theme_background_func = NULL;
|
||||
enable_theme_dialog_texture_func = NULL;
|
||||
get_theme_sys_font_func = NULL;
|
||||
get_theme_sys_color_func = NULL;
|
||||
get_theme_sys_metric_func = NULL;
|
||||
}
|
||||
|
||||
static HTHEME
|
||||
@ -214,6 +235,11 @@ xp_theme_get_handle_by_element (XpThemeElement element)
|
||||
klazz = XP_THEME_CLASS_REBAR;
|
||||
break;
|
||||
|
||||
case XP_THEME_ELEMENT_STATUS_GRIPPER:
|
||||
case XP_THEME_ELEMENT_STATUS_PANE:
|
||||
klazz = XP_THEME_CLASS_STATUS;
|
||||
break;
|
||||
|
||||
case XP_THEME_ELEMENT_TOOLBAR:
|
||||
klazz = XP_THEME_CLASS_TOOLBAR;
|
||||
break;
|
||||
@ -223,6 +249,11 @@ xp_theme_get_handle_by_element (XpThemeElement element)
|
||||
klazz = XP_THEME_CLASS_GLOBALS;
|
||||
break;
|
||||
|
||||
case XP_THEME_ELEMENT_MENUITEM:
|
||||
case XP_THEME_ELEMENT_MENU_SEPARATOR:
|
||||
klazz = XP_THEME_CLASS_MENU;
|
||||
break;
|
||||
|
||||
case XP_THEME_ELEMENT_PRESSED_CHECKBOX:
|
||||
case XP_THEME_ELEMENT_CHECKBOX:
|
||||
case XP_THEME_ELEMENT_BUTTON:
|
||||
@ -306,6 +337,11 @@ xp_theme_map_gtk_state (XpThemeElement element, GtkStateType state)
|
||||
ret = CHEVS_NORMAL;
|
||||
break;
|
||||
|
||||
case XP_THEME_ELEMENT_STATUS_GRIPPER:
|
||||
case XP_THEME_ELEMENT_STATUS_PANE:
|
||||
ret = 1;
|
||||
break;
|
||||
|
||||
case XP_THEME_ELEMENT_CHEVRON:
|
||||
switch (state)
|
||||
{
|
||||
@ -585,6 +621,20 @@ xp_theme_map_gtk_state (XpThemeElement element, GtkStateType state)
|
||||
|
||||
#endif
|
||||
|
||||
case XP_THEME_ELEMENT_MENUITEM:
|
||||
case XP_THEME_ELEMENT_MENU_SEPARATOR:
|
||||
switch(state) {
|
||||
case GTK_STATE_SELECTED:
|
||||
ret = MS_SELECTED;
|
||||
break;
|
||||
case GTK_STATE_INSENSITIVE:
|
||||
ret = MS_DEMOTED;
|
||||
break;
|
||||
default:
|
||||
ret = MS_NORMAL;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
switch(state)
|
||||
{
|
||||
@ -676,7 +726,7 @@ xp_theme_draw (GdkWindow *win, XpThemeElement element, GtkStyle *style,
|
||||
FillRect (dc, &rect, (HBRUSH) (COLOR_3DFACE+1));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
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);
|
||||
|
||||
@ -697,7 +747,7 @@ xp_theme_is_drawable (XpThemeElement element)
|
||||
{
|
||||
xp_theme_reset ();
|
||||
}
|
||||
|
||||
|
||||
if (active)
|
||||
{
|
||||
return (xp_theme_get_handle_by_element (element) != NULL);
|
||||
@ -708,11 +758,55 @@ xp_theme_is_drawable (XpThemeElement element)
|
||||
}
|
||||
|
||||
gboolean
|
||||
xp_theme_get_system_font (int fontId, LOGFONT *lf)
|
||||
xp_theme_get_system_font (XpThemeClass klazz, XpThemeFont fontId, LOGFONT *lf)
|
||||
{
|
||||
int themeFont;
|
||||
|
||||
if (get_theme_sys_font_func != NULL)
|
||||
{
|
||||
return ((*get_theme_sys_font_func)(NULL, fontId, lf) == S_OK);
|
||||
HTHEME theme = xp_theme_get_handle_by_class(klazz);
|
||||
if (!theme)
|
||||
return FALSE;
|
||||
|
||||
switch (fontId){
|
||||
case XP_THEME_FONT_CAPTION:
|
||||
themeFont = TMT_CAPTIONFONT; break;
|
||||
case XP_THEME_FONT_MENU:
|
||||
themeFont = TMT_MENUFONT; break;
|
||||
case XP_THEME_FONT_STATUS:
|
||||
themeFont = TMT_STATUSFONT; break;
|
||||
case XP_THEME_FONT_MESSAGE:
|
||||
default:
|
||||
themeFont = TMT_MSGBOXFONT; break;
|
||||
}
|
||||
/* if theme is NULL, it will just return the GetSystemFont() value */
|
||||
return ((*get_theme_sys_font_func)(theme, themeFont, lf) == S_OK);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean xp_theme_get_system_color (XpThemeClass klazz, int colorId, DWORD * pColor)
|
||||
{
|
||||
if (get_theme_sys_color_func != NULL)
|
||||
{
|
||||
HTHEME theme = xp_theme_get_handle_by_class(klazz);
|
||||
|
||||
/* if theme is NULL, it will just return the GetSystemColor() value */
|
||||
*pColor = (*get_theme_sys_color_func)(theme, colorId);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean xp_theme_get_system_metric (XpThemeClass klazz, int metricId, int * pVal)
|
||||
{
|
||||
if (get_theme_sys_metric_func != NULL)
|
||||
{
|
||||
HTHEME theme = xp_theme_get_handle_by_class(klazz);
|
||||
|
||||
/* if theme is NULL, it will just return the GetSystemMetrics() value */
|
||||
*pVal = (*get_theme_sys_metric_func)(theme, metricId);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -39,6 +39,9 @@ typedef enum
|
||||
XP_THEME_CLASS_REBAR,
|
||||
XP_THEME_CLASS_TOOLBAR,
|
||||
XP_THEME_CLASS_GLOBALS,
|
||||
XP_THEME_CLASS_MENU,
|
||||
XP_THEME_CLASS_WINDOW,
|
||||
XP_THEME_CLASS_STATUS,
|
||||
XP_THEME_CLASS__SIZEOF
|
||||
} XpThemeClass;
|
||||
|
||||
@ -81,11 +84,23 @@ typedef enum
|
||||
XP_THEME_ELEMENT_GRIPPER_V,
|
||||
XP_THEME_ELEMENT_CHEVRON,
|
||||
XP_THEME_ELEMENT_TOOLBAR,
|
||||
XP_THEME_ELEMENT_MENUITEM,
|
||||
XP_THEME_ELEMENT_MENU_SEPARATOR,
|
||||
XP_THEME_ELEMENT_STATUS_GRIPPER,
|
||||
XP_THEME_ELEMENT_STATUS_PANE,
|
||||
XP_THEME_ELEMENT_HLINE,
|
||||
XP_THEME_ELEMENT_VLINE,
|
||||
XP_THEME_ELEMENT__SIZEOF
|
||||
} XpThemeElement;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
XP_THEME_FONT_CAPTION,
|
||||
XP_THEME_FONT_MENU,
|
||||
XP_THEME_FONT_STATUS,
|
||||
XP_THEME_FONT_MESSAGE
|
||||
} XpThemeFont;
|
||||
|
||||
void xp_theme_init (void);
|
||||
void xp_theme_reset (void);
|
||||
void xp_theme_exit (void);
|
||||
@ -94,6 +109,8 @@ 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 (int fontId, LOGFONT *lf);
|
||||
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);
|
||||
|
||||
#endif /* XP_THEME_H */
|
||||
|
Loading…
Reference in New Issue
Block a user