/* Wimp "Windows Impersonator" Engine * * Copyright (C) 2003 Raymond Penners * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "xp_theme.h" #include #include #include #include #include #include #include static 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" }; static const short element_part_map[]= { BP_CHECKBOX, BP_CHECKBOX, BP_PUSHBUTTON, HP_HEADERITEM, CP_DROPDOWNBUTTON, TABP_BODY, TABP_TABITEM, TABP_TABITEMLEFTEDGE, TABP_PANE, SBP_THUMBBTNHORZ, SBP_THUMBBTNVERT, SBP_ARROWBTN, SBP_ARROWBTN, SBP_ARROWBTN, SBP_ARROWBTN, SBP_GRIPPERHORZ, SBP_GRIPPERVERT, SBP_LOWERTRACKHORZ, SBP_LOWERTRACKVERT, EP_EDITTEXT, BP_PUSHBUTTON, SPNP_UP, SPNP_DOWN, BP_RADIOBUTTON, TVP_GLYPH, TVP_GLYPH, PP_CHUNK, PP_CHUNKVERT, PP_BAR, PP_BARVERT, TTP_STANDARD, RP_BAND, RP_GRIPPER, RP_GRIPPERVERT, RP_CHEVRON, TP_BUTTON }; 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); typedef HTHEME (FAR PASCAL *OpenThemeDataFunc) (HWND hwnd, LPCWSTR pszClassList); typedef HRESULT (FAR PASCAL *CloseThemeDataFunc)(HTHEME theme); typedef HRESULT (FAR PASCAL *DrawThemeBackgroundFunc) (HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect); typedef HRESULT (FAR PASCAL *EnableThemeDialogTextureFunc)(HWND hwnd, DWORD dwFlags); static GetThemeSysFontFunc get_theme_sys_font_func = NULL; static OpenThemeDataFunc open_theme_data_func = NULL; static CloseThemeDataFunc close_theme_data_func = NULL; static DrawThemeBackgroundFunc draw_theme_background_func = NULL; static EnableThemeDialogTextureFunc enable_theme_dialog_texture_func = NULL; void xp_theme_init() { int i; if (uxtheme_dll) return; uxtheme_dll = LoadLibrary("uxtheme.dll"); memset(open_themes, 0, sizeof(open_themes)); 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"); } void xp_theme_exit() { int i; if(! uxtheme_dll) return; for (i=0; idark_gc[state_type], NULL); dc = gdk_win32_hdc_get(drawable, style->dark_gc[state_type], 0); if (!dc) return FALSE; part_state = xp_theme_map_gtk_state(element, state_type); draw_theme_background_func(theme, dc, element_part_map[element], part_state, &rect, 0); gdk_win32_hdc_release(drawable, style->dark_gc[state_type], 0); return TRUE; } gboolean xp_theme_is_drawable(XpThemeElement element) { gboolean ret = FALSE; if (uxtheme_dll) { ret = xp_theme_get_handle_by_element(element) != NULL; } return ret; } gboolean xp_theme_get_system_font(LOGFONT *lf) { gboolean ret = FALSE; if (get_theme_sys_font_func != NULL) { HRESULT hr = (*get_theme_sys_font_func)(NULL, TMT_MSGBOXFONT, lf); ret = (hr == S_OK); } return ret; }