* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
static HINSTANCE uxtheme_dll = NULL;
static gboolean use_xp_theme = FALSE;
+static OSVERSIONINFO os_version;
+static HTHEME needs_alpha_fixup1 = NULL;
+static HTHEME needs_alpha_fixup2 = NULL;
+static HTHEME needs_alpha_fixup3 = NULL;
+static HTHEME needs_alpha_fixup4 = NULL;
+static HTHEME needs_alpha_fixup5 = NULL;
+static HTHEME needs_alpha_fixup6 = NULL;
+static HTHEME needs_alpha_fixup7 = NULL;
typedef HRESULT (FAR PASCAL *GetThemeSysFontFunc) (HTHEME hTheme, int iFontID, OUT LOGFONTW *plf);
typedef int (FAR PASCAL *GetThemeSysSizeFunc) (HTHEME hTheme, int iSizeId);
}
hthemes_by_class = g_hash_table_new (g_str_hash, g_str_equal);
+
+ memset (&os_version, 0, sizeof (os_version));
+ os_version.dwOSVersionInfoSize = sizeof (os_version);
+ GetVersionEx (&os_version);
+ if (os_version.dwMajorVersion == 5)
+ {
+ needs_alpha_fixup1 = _gtk_win32_lookup_htheme_by_classname ("scrollbar");
+ needs_alpha_fixup2 = _gtk_win32_lookup_htheme_by_classname ("toolbar");
+ needs_alpha_fixup3 = _gtk_win32_lookup_htheme_by_classname ("button");
+ needs_alpha_fixup4 = _gtk_win32_lookup_htheme_by_classname ("header");
+ needs_alpha_fixup5 = _gtk_win32_lookup_htheme_by_classname ("trackbar");
+ needs_alpha_fixup6 = _gtk_win32_lookup_htheme_by_classname ("status");
+ needs_alpha_fixup7 = _gtk_win32_lookup_htheme_by_classname ("rebar");
+ }
}
HTHEME
int state,
int margins[4],
int width,
- int height)
+ int height,
+ int *x_offs_out,
+ int *y_offs_out)
{
cairo_surface_t *surface;
GdkRGBA color;
cairo_t *cr;
+ int x_offs;
+ int y_offs;
#ifdef G_OS_WIN32
+ gboolean has_alpha;
HDC hdc;
RECT rect;
+ SIZE size;
HRESULT res;
+#endif
- surface = cairo_win32_surface_create_with_dib (CAIRO_FORMAT_ARGB32, width, height);
- hdc = cairo_win32_surface_get_dc (surface);
+ x_offs = margins[3];
+ y_offs = margins[0];
+
+ width -= margins[3] + margins[1];
+ height -= margins[0] + margins[2];
+
+#ifdef G_OS_WIN32
+ rect.left = 0;
+ rect.top = 0;
+ rect.right = width;
+ rect.bottom = height;
+
+ hdc = GetDC (NULL);
+ res = get_theme_part_size (theme, hdc, xp_part, state, &rect, 2, &size);
+ ReleaseDC (NULL, hdc);
+
+ if (res == S_OK)
+ {
+ x_offs += (width - size.cx) / 2;
+ y_offs += (height - size.cy) / 2;
- rect.left = margins[3];
- rect.top = margins[0];
- rect.right = width - margins[1];
- rect.bottom = height - margins[2];
+ width = size.cx;
+ height = size.cy;
+
+ rect.right = width;
+ rect.bottom = height;
+ }
+
+ has_alpha = is_theme_partially_transparent (theme, xp_part, state);
+ if (has_alpha)
+ surface = cairo_win32_surface_create_with_dib (CAIRO_FORMAT_ARGB32, width, height);
+ else
+ surface = cairo_win32_surface_create_with_dib (CAIRO_FORMAT_RGB24, width, height);
+
+ hdc = cairo_win32_surface_get_dc (surface);
res = draw_theme_background (theme, hdc, xp_part, state, &rect, &rect);
+
+ /* XP Can't handle rendering some parts on an alpha target */
+ if (has_alpha &&
+ (theme == needs_alpha_fixup1 ||
+ theme == needs_alpha_fixup2 ||
+ (theme == needs_alpha_fixup3 && xp_part == 4) ||
+ theme == needs_alpha_fixup4 ||
+ theme == needs_alpha_fixup5 ||
+ theme == needs_alpha_fixup6 ||
+ theme == needs_alpha_fixup7))
+ {
+ cairo_surface_t *img = cairo_win32_surface_get_image (surface);
+ guint32 *data = (guint32 *)cairo_image_surface_get_data (img);
+ int i, j;
+ GdiFlush ();
+
+ for (i = 0; i < width; i++)
+ {
+ for (j = 0; j < height; j++)
+ {
+ if (data[i+j*width] != 0)
+ data[i+j*width] |= 0xff000000;
+ }
+ }
+ }
+
+ *x_offs_out = x_offs;
+ *y_offs_out = y_offs;
+
if (res == S_OK)
return surface;
+
#else /* !G_OS_WIN32 */
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
#endif /* G_OS_WIN32 */
cairo_destroy (cr);
+ *x_offs_out = x_offs;
+ *y_offs_out = y_offs;
+
return surface;
}
int
_gtk_win32_theme_int_parse (GtkCssParser *parser,
- GFile *base,
int *value)
{
char *class;
return -1;
}
-GtkSymbolicColor *
-_gtk_win32_theme_color_parse (GtkCssParser *parser)
-{
- GtkSymbolicColor *color;
- char *class;
- int id;
-
- class = _gtk_css_parser_try_name (parser, TRUE);
- if (class == NULL)
- {
- _gtk_css_parser_error (parser,
- "Expected name as first argument to '-gtk-win32-color'");
- return NULL;
- }
-
- if (! _gtk_css_parser_try (parser, ",", TRUE))
- {
- g_free (class);
- _gtk_css_parser_error (parser,
- "Expected ','");
- return NULL;
- }
-
- if (!_gtk_css_parser_try_int (parser, &id))
- {
- g_free (class);
- _gtk_css_parser_error (parser, "Expected a valid integer value");
- return NULL;
- }
-
- color = gtk_symbolic_color_new_win32 (class, id);
- g_free (class);
- return color;
-}
-
gboolean
_gtk_win32_theme_color_resolve (const char *theme_class,
gint id,
#endif
return TRUE;
}
+
+const char *
+_gtk_win32_theme_get_default (void)
+{
+#ifdef G_OS_WIN32
+ _gtk_win32_theme_init ();
+
+ if (use_xp_theme)
+ return (os_version.dwMajorVersion >= 6) ? "gtk-win32" : "gtk-win32-xp";
+#endif
+ return "gtk-win32-classic";
+}
+