Remove win32 themeing support
It was unused through all of GTK 3, so it is not worth supporting. The best Windows themes do not make use of it at all.
This commit is contained in:
@@ -546,7 +546,7 @@ checkbutton:indeterminate {
|
||||
GTK adds several additional ways to specify colors.
|
||||
</para>
|
||||
|
||||
<literallayout><code>〈gtk color〉 = 〈symbolic color〉 | 〈color expression〉 | 〈win32 color〉</code>
|
||||
<literallayout><code>〈gtk color〉 = 〈symbolic color〉 | 〈color expression〉</code>
|
||||
</literallayout>
|
||||
|
||||
<para>
|
||||
@@ -592,13 +592,6 @@ checkbutton:indeterminate {
|
||||
|
||||
<literallayout><code>〈color expression〉 = lighter( 〈color〉 ) | darker( 〈color〉 ) | shade( 〈color〉, 〈number〉 ) |</code>
|
||||
<code> alpha( 〈color〉, 〈number〉 ) | mix( 〈color〉, 〈color〉, 〈number〉 )</code>
|
||||
</literallayout>
|
||||
|
||||
<para>
|
||||
On Windows, GTK allows to refer to system colors, as follows:
|
||||
</para>
|
||||
|
||||
<literallayout><code>〈win32 color〉 = -gtk-win32-color( 〈name〉, 〈integer〉 )</code>
|
||||
</literallayout>
|
||||
|
||||
</refsect2>
|
||||
@@ -737,7 +730,7 @@ label {
|
||||
GTK extends the CSS syntax for images and also uses it for specifying icons.
|
||||
</para>
|
||||
|
||||
<literallayout><code>〈gtk image〉 = 〈themed icon〉 | 〈scaled image〉 | 〈recolored image〉 | 〈win32 theme part〉</code>
|
||||
<literallayout><code>〈gtk image〉 = 〈themed icon〉 | 〈scaled image〉 | 〈recolored image〉</code>
|
||||
</literallayout>
|
||||
|
||||
<para>
|
||||
@@ -815,13 +808,6 @@ arrow {
|
||||
}
|
||||
]]></programlisting>
|
||||
</example>
|
||||
<para>
|
||||
On Windows, GTK allows to refer to system theme parts as images, as follows:
|
||||
</para>
|
||||
|
||||
<literallayout><code>〈win32 theme part〉 = -gtk-win32-theme-part( 〈name〉, 〈integer〉 〈integer〉</code>
|
||||
<code> [ , [ over( 〈integer〉 〈integer〉 [ , 〈alpha value〉 ]? ) | margins( 〈integer〉{1,4} ) ] ]* )</code>
|
||||
</literallayout>
|
||||
|
||||
</refsect2>
|
||||
|
||||
|
||||
@@ -65,20 +65,6 @@ We use <literallayout> for syntax productions, and each line is put in a <code>
|
||||
not quite the same as the CSS definition of rem.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Whereever a number is allowed, GTK also accepts a Windows-specific
|
||||
theme size:
|
||||
</para>
|
||||
|
||||
<literallayout>
|
||||
<code>〈win32 theme size〉 = 〈win32 size〉 | 〈win32 part size〉</code>
|
||||
<code>〈win32 size〉 = -gtk-win32-size ( 〈theme name〉, 〈metric id〉 )</code>
|
||||
<code>〈win32 part size〉 = [ -gtk-win32-part-width | -gtk-win32-part-height |</code>
|
||||
<code> -gtk-win32-part-border-top | -gtk-win32-part-border-right |</code>
|
||||
<code> -gtk-win32-part-border-bottom | -gtk-win32-part-border-left ]</code>
|
||||
<code> ( 〈theme name〉 , 〈integer〉 , 〈integer〉 )</code>
|
||||
</literallayout>
|
||||
|
||||
<literallayout><code>〈calc expression〉 = calc( 〈calc sum〉 )</code>
|
||||
<code>〈calc sum〉 = 〈calc product〉 [ [ + | - ] 〈calc product〉 ]*</code>
|
||||
<code>〈calc product〉 = 〈calc value〉 [ * 〈calc value〉 | / 〈number〉 ]*</code>
|
||||
|
||||
@@ -46,11 +46,6 @@ xml += '\n'
|
||||
for f in get_files('theme/HighContrast/assets', '.svg'):
|
||||
xml += ' <file>theme/HighContrast/assets/{0}</file>\n'.format(f)
|
||||
|
||||
xml += '''
|
||||
<file>theme/win32/gtk-win32-base.css</file>
|
||||
<file>theme/win32/gtk.css</file>
|
||||
'''
|
||||
|
||||
for f in get_files('gesture', '.symbolic.png'):
|
||||
xml += ' <file alias=\'icons/64x64/actions/{0}\'>gesture/{0}</file>\n'.format(f)
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkhslaprivate.h"
|
||||
#include "gtkstylepropertyprivate.h"
|
||||
#include "gtkwin32drawprivate.h"
|
||||
#include "gtkwin32themeprivate.h"
|
||||
|
||||
#include "gtkprivate.h"
|
||||
|
||||
@@ -34,7 +32,6 @@ typedef enum {
|
||||
COLOR_TYPE_SHADE,
|
||||
COLOR_TYPE_ALPHA,
|
||||
COLOR_TYPE_MIX,
|
||||
COLOR_TYPE_WIN32,
|
||||
COLOR_TYPE_CURRENT_COLOR
|
||||
} ColorType;
|
||||
|
||||
@@ -60,12 +57,6 @@ struct _GtkCssValue
|
||||
GtkCssValue *color2;
|
||||
gdouble factor;
|
||||
} mix;
|
||||
|
||||
struct
|
||||
{
|
||||
GtkWin32Theme *theme;
|
||||
gint id;
|
||||
} win32;
|
||||
} sym_col;
|
||||
};
|
||||
|
||||
@@ -90,9 +81,6 @@ gtk_css_value_color_free (GtkCssValue *color)
|
||||
_gtk_css_value_unref (color->sym_col.mix.color1);
|
||||
_gtk_css_value_unref (color->sym_col.mix.color2);
|
||||
break;
|
||||
case COLOR_TYPE_WIN32:
|
||||
gtk_win32_theme_unref (color->sym_col.win32.theme);
|
||||
break;
|
||||
case COLOR_TYPE_LITERAL:
|
||||
case COLOR_TYPE_CURRENT_COLOR:
|
||||
default:
|
||||
@@ -240,18 +228,6 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
|
||||
value =_gtk_css_rgba_value_new_from_rgba (&res);
|
||||
}
|
||||
|
||||
break;
|
||||
case COLOR_TYPE_WIN32:
|
||||
{
|
||||
GdkRGBA res;
|
||||
|
||||
gtk_win32_theme_get_color (color->sym_col.win32.theme,
|
||||
color->sym_col.win32.id,
|
||||
&res);
|
||||
|
||||
value = _gtk_css_rgba_value_new_from_rgba (&res);
|
||||
}
|
||||
|
||||
break;
|
||||
case COLOR_TYPE_CURRENT_COLOR:
|
||||
if (current)
|
||||
@@ -350,9 +326,6 @@ gtk_css_value_color_equal (const GtkCssValue *value1,
|
||||
value2->sym_col.mix.color1) &&
|
||||
_gtk_css_value_equal (value1->sym_col.mix.color2,
|
||||
value2->sym_col.mix.color2);
|
||||
case COLOR_TYPE_WIN32:
|
||||
return gtk_win32_theme_equal (value1->sym_col.win32.theme, value2->sym_col.win32.theme) &&
|
||||
value1->sym_col.win32.id == value2->sym_col.win32.id;
|
||||
case COLOR_TYPE_CURRENT_COLOR:
|
||||
return TRUE;
|
||||
default:
|
||||
@@ -421,20 +394,6 @@ gtk_css_value_color_print (const GtkCssValue *value,
|
||||
g_string_append (string, ")");
|
||||
}
|
||||
break;
|
||||
case COLOR_TYPE_WIN32:
|
||||
{
|
||||
const char *name;
|
||||
g_string_append (string, GTK_WIN32_THEME_SYMBOLIC_COLOR_NAME"(");
|
||||
gtk_win32_theme_print (value->sym_col.win32.theme, string);
|
||||
g_string_append (string, ", ");
|
||||
name = gtk_win32_get_sys_color_name_for_id (value->sym_col.win32.id);
|
||||
if (name)
|
||||
g_string_append (string, name);
|
||||
else
|
||||
g_string_append_printf (string, "%d", value->sym_col.win32.id);
|
||||
g_string_append (string, ")");
|
||||
}
|
||||
break;
|
||||
case COLOR_TYPE_CURRENT_COLOR:
|
||||
g_string_append (string, "currentColor");
|
||||
break;
|
||||
@@ -543,38 +502,6 @@ _gtk_css_color_value_new_mix (GtkCssValue *color1,
|
||||
return value;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_color_value_new_win32_for_theme (GtkWin32Theme *theme,
|
||||
gint id)
|
||||
{
|
||||
GtkCssValue *value;
|
||||
|
||||
gtk_internal_return_val_if_fail (theme != NULL, NULL);
|
||||
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_COLOR);
|
||||
value->type = COLOR_TYPE_WIN32;
|
||||
value->sym_col.win32.theme = gtk_win32_theme_ref (theme);
|
||||
value->sym_col.win32.id = id;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_color_value_new_win32 (const gchar *theme_class,
|
||||
gint id)
|
||||
{
|
||||
GtkWin32Theme *theme;
|
||||
GtkCssValue *value;
|
||||
|
||||
gtk_internal_return_val_if_fail (theme_class != NULL, NULL);
|
||||
|
||||
theme = gtk_win32_theme_lookup (theme_class);
|
||||
value = gtk_css_color_value_new_win32_for_theme (theme, id);
|
||||
gtk_win32_theme_unref (theme);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_color_value_new_current_color (void)
|
||||
{
|
||||
@@ -590,54 +517,9 @@ typedef enum {
|
||||
COLOR_DARKER,
|
||||
COLOR_SHADE,
|
||||
COLOR_ALPHA,
|
||||
COLOR_MIX,
|
||||
COLOR_WIN32
|
||||
COLOR_MIX
|
||||
} ColorParseType;
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_color_parse_win32 (GtkCssParser *parser)
|
||||
{
|
||||
GtkCssValue *color;
|
||||
GtkWin32Theme *theme;
|
||||
char *name;
|
||||
int id;
|
||||
|
||||
theme = gtk_win32_theme_parse (parser);
|
||||
if (theme == NULL)
|
||||
return NULL;
|
||||
|
||||
if (! _gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
gtk_win32_theme_unref (theme);
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected ','");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
name = _gtk_css_parser_try_ident (parser, TRUE);
|
||||
if (name)
|
||||
{
|
||||
id = gtk_win32_get_sys_color_id_for_name (name);
|
||||
if (id == -1)
|
||||
{
|
||||
_gtk_css_parser_error (parser, "'%s' is not a win32 color name.", name);
|
||||
g_free (name);
|
||||
return NULL;
|
||||
}
|
||||
g_free (name);
|
||||
}
|
||||
else if (!_gtk_css_parser_try_int (parser, &id))
|
||||
{
|
||||
gtk_win32_theme_unref (theme);
|
||||
_gtk_css_parser_error (parser, "Expected a valid integer value");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
color = gtk_css_color_value_new_win32_for_theme (theme, id);
|
||||
gtk_win32_theme_unref (theme);
|
||||
return color;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
_gtk_css_color_value_parse_function (GtkCssParser *parser,
|
||||
ColorParseType color)
|
||||
@@ -704,12 +586,6 @@ _gtk_css_color_value_parse_function (GtkCssParser *parser,
|
||||
|
||||
value = _gtk_css_color_value_new_literal (&rgba);
|
||||
}
|
||||
else if (color == COLOR_WIN32)
|
||||
{
|
||||
value = gtk_css_color_parse_win32 (parser);
|
||||
if (value == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
child1 = _gtk_css_color_value_parse (parser);
|
||||
@@ -775,7 +651,6 @@ _gtk_css_color_value_parse_function (GtkCssParser *parser,
|
||||
break;
|
||||
case COLOR_RGB:
|
||||
case COLOR_RGBA:
|
||||
case COLOR_WIN32:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
value = NULL;
|
||||
@@ -802,8 +677,7 @@ _gtk_css_color_value_parse (GtkCssParser *parser)
|
||||
GtkCssValue *value;
|
||||
GdkRGBA rgba;
|
||||
guint color;
|
||||
const char *names[] = {"rgba", "rgb", "lighter", "darker", "shade", "alpha", "mix",
|
||||
GTK_WIN32_THEME_SYMBOLIC_COLOR_NAME};
|
||||
const char *names[] = {"rgba", "rgb", "lighter", "darker", "shade", "alpha", "mix"};
|
||||
char *name;
|
||||
|
||||
if (_gtk_css_parser_try (parser, "currentColor", TRUE))
|
||||
|
||||
@@ -37,8 +37,6 @@ GtkCssValue * _gtk_css_color_value_new_alpha (GtkCssValue *color,
|
||||
GtkCssValue * _gtk_css_color_value_new_mix (GtkCssValue *color1,
|
||||
GtkCssValue *color2,
|
||||
gdouble factor);
|
||||
GtkCssValue * _gtk_css_color_value_new_win32 (const gchar *theme_class,
|
||||
gint id);
|
||||
GtkCssValue * _gtk_css_color_value_new_current_color (void);
|
||||
|
||||
GtkCssValue * _gtk_css_color_value_parse (GtkCssParser *parser);
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "gtk/gtkcssimagescaledprivate.h"
|
||||
#include "gtk/gtkcssimagerecolorprivate.h"
|
||||
#include "gtk/gtkcssimagefallbackprivate.h"
|
||||
#include "gtk/gtkcssimagewin32private.h"
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (GtkCssImage, _gtk_css_image, G_TYPE_OBJECT)
|
||||
|
||||
@@ -499,7 +498,6 @@ gtk_css_image_get_parser_type (GtkCssParser *parser)
|
||||
{ "-gtk-icontheme", _gtk_css_image_icon_theme_get_type },
|
||||
{ "-gtk-scaled", _gtk_css_image_scaled_get_type },
|
||||
{ "-gtk-recolor", _gtk_css_image_recolor_get_type },
|
||||
{ "-gtk-win32-theme-part", _gtk_css_image_win32_get_type },
|
||||
{ "linear-gradient", _gtk_css_image_linear_get_type },
|
||||
{ "repeating-linear-gradient", _gtk_css_image_linear_get_type },
|
||||
{ "radial-gradient", _gtk_css_image_radial_get_type },
|
||||
|
||||
@@ -1,263 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2011 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 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
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcssimagewin32private.h"
|
||||
|
||||
#include "gtkcssprovider.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkCssImageWin32, _gtk_css_image_win32, GTK_TYPE_CSS_IMAGE)
|
||||
|
||||
static void
|
||||
gtk_css_image_win32_snapshot (GtkCssImage *image,
|
||||
GtkSnapshot *snapshot,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
GtkCssImageWin32 *wimage = GTK_CSS_IMAGE_WIN32 (image);
|
||||
cairo_surface_t *surface;
|
||||
int dx, dy;
|
||||
cairo_t *cr;
|
||||
|
||||
cr = gtk_snapshot_append_cairo (snapshot,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
|
||||
surface = gtk_win32_theme_create_surface (wimage->theme, wimage->part, wimage->state, wimage->margins,
|
||||
width, height, &dx, &dy);
|
||||
|
||||
if (wimage->state2 >= 0)
|
||||
{
|
||||
cairo_surface_t *surface2;
|
||||
cairo_t *cr2;
|
||||
int dx2, dy2;
|
||||
|
||||
surface2 = gtk_win32_theme_create_surface (wimage->theme, wimage->part2, wimage->state2, wimage->margins,
|
||||
width, height, &dx2, &dy2);
|
||||
|
||||
cr2 = cairo_create (surface);
|
||||
|
||||
cairo_set_source_surface (cr2, surface2, dx2 - dx, dy2-dy);
|
||||
cairo_paint_with_alpha (cr2, wimage->over_alpha);
|
||||
|
||||
cairo_destroy (cr2);
|
||||
|
||||
cairo_surface_destroy (surface2);
|
||||
}
|
||||
|
||||
cairo_set_source_surface (cr, surface, dx, dy);
|
||||
cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_NONE);
|
||||
cairo_rectangle (cr, 0, 0, width, height);
|
||||
cairo_fill (cr);
|
||||
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_image_win32_parse (GtkCssImage *image,
|
||||
GtkCssParser *parser)
|
||||
{
|
||||
GtkCssImageWin32 *wimage = GTK_CSS_IMAGE_WIN32 (image);
|
||||
|
||||
if (!_gtk_css_parser_try (parser, "-gtk-win32-theme-part", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "'-gtk-win32-theme-part'");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try (parser, "(", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected '(' after '-gtk-win32-theme-part'");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
wimage->theme = gtk_win32_theme_parse (parser);
|
||||
if (wimage->theme == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (! _gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected ','");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_int (parser, &wimage->part))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected a valid integer value");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (! _gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected ','");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_int (parser, &wimage->state))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected a valid integer value");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while ( _gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
if ( _gtk_css_parser_try (parser, "over", TRUE))
|
||||
{
|
||||
if (!_gtk_css_parser_try (parser, "(", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected '(' after 'over'");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_int (parser, &wimage->part2))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected a valid integer value");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (! _gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected ','");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_int (parser, &wimage->state2))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected a valid integer value");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( _gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
if (!_gtk_css_parser_try_double (parser, &wimage->over_alpha))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected a valid double value");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ")", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected ')' at end of 'over'");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else if ( _gtk_css_parser_try (parser, "margins", TRUE))
|
||||
{
|
||||
guint i;
|
||||
|
||||
if (!_gtk_css_parser_try (parser, "(", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected '(' after 'margins'");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (!_gtk_css_parser_try_int (parser, &wimage->margins[i]))
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected valid margins");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (i == 1)
|
||||
wimage->margins[1] = wimage->margins[0];
|
||||
if (i <= 2)
|
||||
wimage->margins[2] = wimage->margins[1];
|
||||
if (i <= 3)
|
||||
wimage->margins[3] = wimage->margins[2];
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ")", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected ')' at end of 'margins'");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected identifier");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ")", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected ')'");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_win32_print (GtkCssImage *image,
|
||||
GString *string)
|
||||
{
|
||||
GtkCssImageWin32 *wimage = GTK_CSS_IMAGE_WIN32 (image);
|
||||
|
||||
g_string_append (string, "-gtk-win32-theme-part(");
|
||||
gtk_win32_theme_print (wimage->theme, string);
|
||||
g_string_append_printf (string, ", %d, %d)", wimage->part, wimage->state);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_win32_finalize (GObject *object)
|
||||
{
|
||||
GtkCssImageWin32 *wimage = GTK_CSS_IMAGE_WIN32 (object);
|
||||
|
||||
if (wimage->theme)
|
||||
gtk_win32_theme_unref (wimage->theme);
|
||||
|
||||
G_OBJECT_CLASS (_gtk_css_image_win32_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_css_image_win32_class_init (GtkCssImageWin32Class *klass)
|
||||
{
|
||||
GtkCssImageClass *image_class = GTK_CSS_IMAGE_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_css_image_win32_finalize;
|
||||
|
||||
image_class->snapshot = gtk_css_image_win32_snapshot;
|
||||
image_class->parse = gtk_css_image_win32_parse;
|
||||
image_class->print = gtk_css_image_win32_print;
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_css_image_win32_init (GtkCssImageWin32 *wimage)
|
||||
{
|
||||
wimage->over_alpha = 1.0;
|
||||
wimage->part2 = -1;
|
||||
wimage->state2 = -1;
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2011 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 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
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_IMAGE_WIN32_PRIVATE_H__
|
||||
#define __GTK_CSS_IMAGE_WIN32_PRIVATE_H__
|
||||
|
||||
#include "gtk/gtkcssimageprivate.h"
|
||||
#include "gtk/gtkwin32themeprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_CSS_IMAGE_WIN32 (_gtk_css_image_win32_get_type ())
|
||||
#define GTK_CSS_IMAGE_WIN32(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_IMAGE_WIN32, GtkCssImageWin32))
|
||||
#define GTK_CSS_IMAGE_WIN32_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_IMAGE_WIN32, GtkCssImageWin32Class))
|
||||
#define GTK_IS_CSS_IMAGE_WIN32(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_IMAGE_WIN32))
|
||||
#define GTK_IS_CSS_IMAGE_WIN32_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_IMAGE_WIN32))
|
||||
#define GTK_CSS_IMAGE_WIN32_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_IMAGE_WIN32, GtkCssImageWin32Class))
|
||||
|
||||
typedef struct _GtkCssImageWin32 GtkCssImageWin32;
|
||||
typedef struct _GtkCssImageWin32Class GtkCssImageWin32Class;
|
||||
|
||||
struct _GtkCssImageWin32
|
||||
{
|
||||
GtkCssImage parent;
|
||||
|
||||
int part;
|
||||
int state;
|
||||
|
||||
double over_alpha;
|
||||
int part2;
|
||||
int state2;
|
||||
|
||||
gint margins[4];
|
||||
|
||||
GtkWin32Theme *theme;
|
||||
};
|
||||
|
||||
struct _GtkCssImageWin32Class
|
||||
{
|
||||
GtkCssImageClass parent_class;
|
||||
};
|
||||
|
||||
GType _gtk_css_image_win32_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_IMAGE_WIN32_PRIVATE_H__ */
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
#include "gtkcsscalcvalueprivate.h"
|
||||
#include "gtkcssdimensionvalueprivate.h"
|
||||
#include "gtkcsswin32sizevalueprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
struct _GtkCssValue {
|
||||
@@ -131,14 +130,7 @@ gboolean
|
||||
gtk_css_number_value_can_parse (GtkCssParser *parser)
|
||||
{
|
||||
return _gtk_css_parser_has_number (parser)
|
||||
|| _gtk_css_parser_has_prefix (parser, "calc")
|
||||
|| _gtk_css_parser_has_prefix (parser, "-gtk-win32-size")
|
||||
|| _gtk_css_parser_has_prefix (parser, "-gtk-win32-part-width")
|
||||
|| _gtk_css_parser_has_prefix (parser, "-gtk-win32-part-height")
|
||||
|| _gtk_css_parser_has_prefix (parser, "-gtk-win32-part-border-top")
|
||||
|| _gtk_css_parser_has_prefix (parser, "-gtk-win32-part-border-left")
|
||||
|| _gtk_css_parser_has_prefix (parser, "-gtk-win32-part-border-bottom")
|
||||
|| _gtk_css_parser_has_prefix (parser, "-gtk-win32-part-border-right");
|
||||
|| _gtk_css_parser_has_prefix (parser, "calc");
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
@@ -147,14 +139,6 @@ _gtk_css_number_value_parse (GtkCssParser *parser,
|
||||
{
|
||||
if (_gtk_css_parser_has_prefix (parser, "calc"))
|
||||
return gtk_css_calc_value_parse (parser, flags);
|
||||
if (_gtk_css_parser_has_prefix (parser, "-gtk-win32-size") ||
|
||||
_gtk_css_parser_has_prefix (parser, "-gtk-win32-part-width") ||
|
||||
_gtk_css_parser_has_prefix (parser, "-gtk-win32-part-height") ||
|
||||
_gtk_css_parser_has_prefix (parser, "-gtk-win32-part-border-top") ||
|
||||
_gtk_css_parser_has_prefix (parser, "-gtk-win32-part-border-left") ||
|
||||
_gtk_css_parser_has_prefix (parser, "-gtk-win32-part-border-bottom") ||
|
||||
_gtk_css_parser_has_prefix (parser, "-gtk-win32-part-border-right"))
|
||||
return gtk_css_win32_size_value_parse (parser, flags);
|
||||
|
||||
return gtk_css_dimension_value_parse (parser, flags);
|
||||
}
|
||||
|
||||
@@ -1,407 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcsswin32sizevalueprivate.h"
|
||||
|
||||
#include "gtkwin32drawprivate.h"
|
||||
#include "gtkwin32themeprivate.h"
|
||||
|
||||
typedef enum {
|
||||
GTK_WIN32_SIZE,
|
||||
GTK_WIN32_PART_WIDTH,
|
||||
GTK_WIN32_PART_HEIGHT,
|
||||
GTK_WIN32_PART_BORDER_TOP,
|
||||
GTK_WIN32_PART_BORDER_RIGHT,
|
||||
GTK_WIN32_PART_BORDER_BOTTOM,
|
||||
GTK_WIN32_PART_BORDER_LEFT
|
||||
} GtkWin32SizeType;
|
||||
|
||||
static const char *css_value_names[] = {
|
||||
"-gtk-win32-size(",
|
||||
"-gtk-win32-part-width(",
|
||||
"-gtk-win32-part-height(",
|
||||
"-gtk-win32-part-border-top(",
|
||||
"-gtk-win32-part-border-right(",
|
||||
"-gtk-win32-part-border-bottom(",
|
||||
"-gtk-win32-part-border-left("
|
||||
};
|
||||
|
||||
struct _GtkCssValue {
|
||||
GTK_CSS_VALUE_BASE
|
||||
double scale; /* needed for calc() math */
|
||||
GtkWin32Theme *theme;
|
||||
GtkWin32SizeType type;
|
||||
union {
|
||||
struct {
|
||||
gint id;
|
||||
} size;
|
||||
struct {
|
||||
gint part;
|
||||
gint state;
|
||||
} part;
|
||||
} val;
|
||||
};
|
||||
|
||||
static GtkCssValue * gtk_css_win32_size_value_new (double scale,
|
||||
GtkWin32Theme *theme,
|
||||
GtkWin32SizeType type);
|
||||
|
||||
static void
|
||||
gtk_css_value_win32_size_free (GtkCssValue *value)
|
||||
{
|
||||
gtk_win32_theme_unref (value->theme);
|
||||
g_slice_free (GtkCssValue, value);
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_css_value_win32_compute_size (const GtkCssValue *value)
|
||||
{
|
||||
GtkBorder border;
|
||||
int size;
|
||||
|
||||
switch (value->type)
|
||||
{
|
||||
case GTK_WIN32_SIZE:
|
||||
size = gtk_win32_theme_get_size (value->theme, value->val.size.id);
|
||||
break;
|
||||
|
||||
case GTK_WIN32_PART_WIDTH:
|
||||
gtk_win32_theme_get_part_size (value->theme, value->val.part.part, value->val.part.state, &size, NULL);
|
||||
break;
|
||||
|
||||
case GTK_WIN32_PART_HEIGHT:
|
||||
gtk_win32_theme_get_part_size (value->theme, value->val.part.part, value->val.part.state, NULL, &size);
|
||||
break;
|
||||
|
||||
case GTK_WIN32_PART_BORDER_TOP:
|
||||
gtk_win32_theme_get_part_border (value->theme, value->val.part.part, value->val.part.state, &border);
|
||||
size = border.top;
|
||||
break;
|
||||
|
||||
case GTK_WIN32_PART_BORDER_RIGHT:
|
||||
gtk_win32_theme_get_part_border (value->theme, value->val.part.part, value->val.part.state, &border);
|
||||
size = border.right;
|
||||
break;
|
||||
|
||||
case GTK_WIN32_PART_BORDER_BOTTOM:
|
||||
gtk_win32_theme_get_part_border (value->theme, value->val.part.part, value->val.part.state, &border);
|
||||
size = border.bottom;
|
||||
break;
|
||||
|
||||
case GTK_WIN32_PART_BORDER_LEFT:
|
||||
gtk_win32_theme_get_part_border (value->theme, value->val.part.part, value->val.part.state, &border);
|
||||
size = border.left;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_win32_size_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
return _gtk_css_number_value_new (value->scale * gtk_css_value_win32_compute_size (value), GTK_CSS_PX);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_value_win32_size_equal (const GtkCssValue *value1,
|
||||
const GtkCssValue *value2)
|
||||
{
|
||||
if (value1->type != value2->type ||
|
||||
!gtk_win32_theme_equal (value1->theme, value2->theme) )
|
||||
return FALSE;
|
||||
|
||||
switch (value1->type)
|
||||
{
|
||||
case GTK_WIN32_SIZE:
|
||||
return value1->val.size.id == value2->val.size.id;
|
||||
|
||||
case GTK_WIN32_PART_WIDTH:
|
||||
case GTK_WIN32_PART_HEIGHT:
|
||||
return value1->val.part.part == value2->val.part.part
|
||||
&& value1->val.part.state == value2->val.part.state;
|
||||
|
||||
case GTK_WIN32_PART_BORDER_TOP:
|
||||
case GTK_WIN32_PART_BORDER_RIGHT:
|
||||
case GTK_WIN32_PART_BORDER_BOTTOM:
|
||||
case GTK_WIN32_PART_BORDER_LEFT:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_value_win32_size_print (const GtkCssValue *value,
|
||||
GString *string)
|
||||
{
|
||||
if (value->scale != 1.0)
|
||||
{
|
||||
g_string_append_printf (string, "%g * ", value->scale);
|
||||
}
|
||||
g_string_append (string, css_value_names[value->type]);
|
||||
gtk_win32_theme_print (value->theme, string);
|
||||
|
||||
switch (value->type)
|
||||
{
|
||||
case GTK_WIN32_SIZE:
|
||||
{
|
||||
const char *name = gtk_win32_get_sys_metric_name_for_id (value->val.size.id);
|
||||
if (name)
|
||||
g_string_append (string, name);
|
||||
else
|
||||
g_string_append_printf (string, ", %d", value->val.size.id);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_WIN32_PART_WIDTH:
|
||||
case GTK_WIN32_PART_HEIGHT:
|
||||
case GTK_WIN32_PART_BORDER_TOP:
|
||||
case GTK_WIN32_PART_BORDER_RIGHT:
|
||||
case GTK_WIN32_PART_BORDER_BOTTOM:
|
||||
case GTK_WIN32_PART_BORDER_LEFT:
|
||||
g_string_append_printf (string, ", %d, %d", value->val.part.part, value->val.part.state);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
g_string_append (string, ")");
|
||||
}
|
||||
|
||||
static double
|
||||
gtk_css_value_win32_size_get (const GtkCssValue *value,
|
||||
double one_hundred_percent)
|
||||
{
|
||||
return value->scale * gtk_css_value_win32_compute_size (value);
|
||||
}
|
||||
|
||||
static GtkCssDimension
|
||||
gtk_css_value_win32_size_get_dimension (const GtkCssValue *value)
|
||||
{
|
||||
return GTK_CSS_DIMENSION_LENGTH;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_css_value_win32_size_has_percent (const GtkCssValue *value)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_win32_size_multiply (const GtkCssValue *value,
|
||||
double factor)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
|
||||
result = gtk_css_win32_size_value_new (value->scale * factor, value->theme, value->type);
|
||||
result->val = value->val;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_win32_size_try_add (const GtkCssValue *value1,
|
||||
const GtkCssValue *value2)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
|
||||
if (!gtk_css_value_win32_size_equal (value1, value2))
|
||||
return NULL;
|
||||
|
||||
result = gtk_css_win32_size_value_new (value1->scale + value2->scale, value1->theme, value1->type);
|
||||
result->val = value1->val;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static gint
|
||||
gtk_css_value_win32_size_get_calc_term_order (const GtkCssValue *value)
|
||||
{
|
||||
return 2000 + 100 * value->type;
|
||||
}
|
||||
|
||||
static const GtkCssNumberValueClass GTK_CSS_VALUE_WIN32_SIZE = {
|
||||
{
|
||||
gtk_css_value_win32_size_free,
|
||||
gtk_css_value_win32_size_compute,
|
||||
gtk_css_value_win32_size_equal,
|
||||
gtk_css_number_value_transition,
|
||||
NULL,
|
||||
NULL,
|
||||
gtk_css_value_win32_size_print
|
||||
},
|
||||
gtk_css_value_win32_size_get,
|
||||
gtk_css_value_win32_size_get_dimension,
|
||||
gtk_css_value_win32_size_has_percent,
|
||||
gtk_css_value_win32_size_multiply,
|
||||
gtk_css_value_win32_size_try_add,
|
||||
gtk_css_value_win32_size_get_calc_term_order
|
||||
};
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_win32_size_value_new (double scale,
|
||||
GtkWin32Theme *theme,
|
||||
GtkWin32SizeType type)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
|
||||
result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_WIN32_SIZE.value_class);
|
||||
result->scale = scale;
|
||||
result->theme = gtk_win32_theme_ref (theme);
|
||||
result->type = type;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_win32_size_value_parse_size (GtkCssValue *value,
|
||||
GtkCssParser *parser)
|
||||
{
|
||||
char *name;
|
||||
|
||||
name = _gtk_css_parser_try_ident (parser, TRUE);
|
||||
if (name)
|
||||
{
|
||||
value->val.size.id = gtk_win32_get_sys_metric_id_for_name (name);
|
||||
if (value->val.size.id == -1)
|
||||
{
|
||||
_gtk_css_parser_error (parser, "'%s' is not a name for a win32 metric.", name);
|
||||
_gtk_css_value_unref (value);
|
||||
g_free (name);
|
||||
return NULL;
|
||||
}
|
||||
g_free (name);
|
||||
}
|
||||
else if (!_gtk_css_parser_try_int (parser, &value->val.size.id))
|
||||
{
|
||||
_gtk_css_value_unref (value);
|
||||
_gtk_css_parser_error (parser, "Expected an integer ID");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_win32_size_value_parse_part_size (GtkCssValue *value,
|
||||
GtkCssParser *parser)
|
||||
{
|
||||
if (!_gtk_css_parser_try_int (parser, &value->val.part.part))
|
||||
{
|
||||
_gtk_css_value_unref (value);
|
||||
_gtk_css_parser_error (parser, "Expected an integer part ID");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (! _gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
_gtk_css_value_unref (value);
|
||||
_gtk_css_parser_error (parser, "Expected ','");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_int (parser, &value->val.part.state))
|
||||
{
|
||||
_gtk_css_value_unref (value);
|
||||
_gtk_css_parser_error (parser, "Expected an integer state ID");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_win32_size_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags)
|
||||
{
|
||||
GtkWin32Theme *theme;
|
||||
GtkCssValue *result;
|
||||
guint type;
|
||||
|
||||
for (type = 0; type < G_N_ELEMENTS(css_value_names); type++)
|
||||
{
|
||||
if (_gtk_css_parser_try (parser, css_value_names[type], TRUE))
|
||||
break;
|
||||
}
|
||||
|
||||
if (type >= G_N_ELEMENTS(css_value_names))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Not a win32 size value");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
theme = gtk_win32_theme_parse (parser);
|
||||
if (theme == NULL)
|
||||
return NULL;
|
||||
|
||||
result = gtk_css_win32_size_value_new (1.0, theme, type);
|
||||
gtk_win32_theme_unref (theme);
|
||||
|
||||
if (! _gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
_gtk_css_value_unref (result);
|
||||
_gtk_css_parser_error (parser, "Expected ','");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (result->type)
|
||||
{
|
||||
case GTK_WIN32_SIZE:
|
||||
result = gtk_css_win32_size_value_parse_size (result, parser);
|
||||
break;
|
||||
|
||||
case GTK_WIN32_PART_WIDTH:
|
||||
case GTK_WIN32_PART_HEIGHT:
|
||||
case GTK_WIN32_PART_BORDER_TOP:
|
||||
case GTK_WIN32_PART_BORDER_RIGHT:
|
||||
case GTK_WIN32_PART_BORDER_BOTTOM:
|
||||
case GTK_WIN32_PART_BORDER_LEFT:
|
||||
result = gtk_css_win32_size_value_parse_part_size (result, parser);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
_gtk_css_value_unref (result);
|
||||
result = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ")", TRUE))
|
||||
{
|
||||
_gtk_css_value_unref (result);
|
||||
_gtk_css_parser_error (parser, "Expected ')'");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2012 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 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
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alexander Larsson <alexl@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CSS_WIN32_SIZE_VALUE_PRIVATE_H__
|
||||
#define __GTK_CSS_WIN32_SIZE_VALUE_PRIVATE_H__
|
||||
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * gtk_css_win32_size_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_WIN32_SIZE_VALUE_PRIVATE_H__ */
|
||||
@@ -1,803 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2016 Benjamin Otte <otte@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "gtkwin32drawprivate.h"
|
||||
|
||||
typedef enum {
|
||||
ICON_CLOSE,
|
||||
ICON_MINIMIZE,
|
||||
ICON_MAXIMIZE,
|
||||
ICON_RESTORE
|
||||
} Icon;
|
||||
|
||||
const guchar icon_close_pixels[] = {
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x0c, 0x06, 0x00, 0x00,
|
||||
0x1c, 0x07, 0x00, 0x00,
|
||||
0xb8, 0x03, 0x00, 0x00,
|
||||
0xf0, 0x01, 0x00, 0x00,
|
||||
0xe0, 0x00, 0x00, 0x00,
|
||||
0xf0, 0x01, 0x00, 0x00,
|
||||
0xb8, 0x03, 0x00, 0x00,
|
||||
0x1c, 0x07, 0x00, 0x00,
|
||||
0x0c, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const guchar icon_minimize_pixels[] = {
|
||||
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, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xfc, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const guchar icon_maximize_pixels[] = {
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xfe, 0x07, 0x00, 0x00,
|
||||
0xfe, 0x07, 0x00, 0x00,
|
||||
0x02, 0x04, 0x00, 0x00,
|
||||
0x02, 0x04, 0x00, 0x00,
|
||||
0x02, 0x04, 0x00, 0x00,
|
||||
0x02, 0x04, 0x00, 0x00,
|
||||
0x02, 0x04, 0x00, 0x00,
|
||||
0x02, 0x04, 0x00, 0x00,
|
||||
0xfe, 0x07, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const guchar icon_restore_pixels[] = {
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xf8, 0x07, 0x00, 0x00,
|
||||
0xf8, 0x07, 0x00, 0x00,
|
||||
0x08, 0x04, 0x00, 0x00,
|
||||
0x08, 0x04, 0x00, 0x00,
|
||||
0xfe, 0x04, 0x00, 0x00,
|
||||
0x82, 0x07, 0x00, 0x00,
|
||||
0x82, 0x00, 0x00, 0x00,
|
||||
0x82, 0x00, 0x00, 0x00,
|
||||
0xfe, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
static struct {
|
||||
int width;
|
||||
int height;
|
||||
gsize pixels_size;
|
||||
const guchar *pixels;
|
||||
} icon_masks[] = {
|
||||
{ 13, 13, sizeof (icon_close_pixels), icon_close_pixels },
|
||||
{ 13, 13, sizeof (icon_minimize_pixels), icon_minimize_pixels },
|
||||
{ 13, 13, sizeof (icon_maximize_pixels), icon_maximize_pixels },
|
||||
{ 13, 13, sizeof (icon_restore_pixels), icon_restore_pixels }
|
||||
};
|
||||
|
||||
static void
|
||||
mask_icon (cairo_t *cr,
|
||||
Icon icon,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
|
||||
surface = cairo_image_surface_create_for_data ((guchar *) icon_masks[icon].pixels,
|
||||
CAIRO_FORMAT_A1,
|
||||
icon_masks[icon].width,
|
||||
icon_masks[icon].height,
|
||||
icon_masks[icon].pixels_size / icon_masks[icon].height);
|
||||
cairo_mask_surface (cr,
|
||||
surface,
|
||||
x + (width - icon_masks[icon].width) / 2,
|
||||
y + (height - icon_masks[icon].height) / 2);
|
||||
cairo_surface_destroy (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cairo_set_source_sys_color (cairo_t *cr,
|
||||
gint id)
|
||||
{
|
||||
GdkRGBA rgba;
|
||||
|
||||
gtk_win32_get_sys_color (id, &rgba);
|
||||
gdk_cairo_set_source_rgba (cr, &rgba);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_outline (cairo_t *cr,
|
||||
int top_color_id,
|
||||
int bottom_color_id,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
gtk_cairo_set_source_sys_color (cr, top_color_id);
|
||||
cairo_rectangle (cr, x, y, width, 1);
|
||||
cairo_rectangle (cr, x, y, 1, height);
|
||||
cairo_fill (cr);
|
||||
|
||||
gtk_cairo_set_source_sys_color (cr, bottom_color_id);
|
||||
cairo_rectangle (cr, x + width, y + height, -1, -height);
|
||||
cairo_rectangle (cr, x + width, y + height, -width, -1);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
EDGE_RAISED_OUTER = 1 << 0,
|
||||
EDGE_SUNKEN_OUTER = 1 << 1,
|
||||
EDGE_RAISED_INNER = 1 << 2,
|
||||
EDGE_SUNKEN_INNER = 1 << 3,
|
||||
EDGE_RAISED = (EDGE_RAISED_OUTER | EDGE_RAISED_INNER),
|
||||
EDGE_SUNKEN = (EDGE_SUNKEN_OUTER | EDGE_SUNKEN_INNER),
|
||||
EDGE_ETCHED = (EDGE_SUNKEN_OUTER | EDGE_RAISED_INNER),
|
||||
EDGE_BUMP = (EDGE_RAISED_OUTER | EDGE_SUNKEN_INNER)
|
||||
} GtkWin32Edge;
|
||||
|
||||
static void
|
||||
draw_edge (cairo_t *cr,
|
||||
GtkWin32Edge edge,
|
||||
gboolean soft,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
switch (edge & (EDGE_RAISED_OUTER | EDGE_SUNKEN_OUTER))
|
||||
{
|
||||
case EDGE_RAISED_OUTER:
|
||||
draw_outline (cr,
|
||||
soft ? GTK_WIN32_SYS_COLOR_BTNHIGHLIGHT : GTK_WIN32_SYS_COLOR_3DLIGHT,
|
||||
GTK_WIN32_SYS_COLOR_3DDKSHADOW,
|
||||
x, y, width, height);
|
||||
break;
|
||||
case EDGE_SUNKEN_OUTER:
|
||||
draw_outline (cr,
|
||||
soft ? GTK_WIN32_SYS_COLOR_3DDKSHADOW : GTK_WIN32_SYS_COLOR_BTNSHADOW,
|
||||
GTK_WIN32_SYS_COLOR_BTNHIGHLIGHT,
|
||||
x, y, width, height);
|
||||
break;
|
||||
case (EDGE_RAISED_OUTER | EDGE_SUNKEN_OUTER):
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
x += 1;
|
||||
y += 1;
|
||||
width -= 2;
|
||||
height -= 2;
|
||||
|
||||
switch (edge & (EDGE_RAISED_INNER | EDGE_SUNKEN_INNER))
|
||||
{
|
||||
case EDGE_RAISED_INNER:
|
||||
draw_outline (cr,
|
||||
soft ? GTK_WIN32_SYS_COLOR_3DLIGHT : GTK_WIN32_SYS_COLOR_BTNHIGHLIGHT,
|
||||
GTK_WIN32_SYS_COLOR_BTNSHADOW,
|
||||
x, y, width, height);
|
||||
break;
|
||||
case EDGE_SUNKEN_INNER:
|
||||
draw_outline (cr,
|
||||
soft ? GTK_WIN32_SYS_COLOR_BTNSHADOW : GTK_WIN32_SYS_COLOR_3DDKSHADOW,
|
||||
GTK_WIN32_SYS_COLOR_3DLIGHT,
|
||||
x, y, width, height);
|
||||
break;
|
||||
case (EDGE_RAISED_INNER | EDGE_SUNKEN_INNER):
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_button (cairo_t *cr,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
draw_edge (cr, state == 3 ? EDGE_SUNKEN : EDGE_RAISED, TRUE, 0, 0, width, height);
|
||||
|
||||
gtk_cairo_set_source_sys_color (cr, GTK_WIN32_SYS_COLOR_BTNFACE);
|
||||
cairo_rectangle (cr, 2, 2, width - 4, height - 4);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_frame (cairo_t *cr,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
draw_edge (cr, EDGE_ETCHED, FALSE, 0, 0, width, height);
|
||||
|
||||
gtk_cairo_set_source_sys_color (cr, GTK_WIN32_SYS_COLOR_BTNFACE);
|
||||
cairo_rectangle (cr, 2, 2, width - 4, height - 4);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_check (cairo_t *cr,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
gtk_cairo_set_source_sys_color (cr, GTK_WIN32_SYS_COLOR_BTNHIGHLIGHT);
|
||||
cairo_set_line_width (cr, 1.0);
|
||||
cairo_rectangle (cr, 0.5, 0.5, width - 1.0, height - 1.0);
|
||||
cairo_stroke (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_radio (cairo_t *cr,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
gtk_cairo_set_source_sys_color (cr, GTK_WIN32_SYS_COLOR_BTNHIGHLIGHT);
|
||||
cairo_set_line_width (cr, 1.0);
|
||||
cairo_arc (cr, width / 2.0, height / 2.0, MIN (width, height) / 2.0 - 0.5, 0, G_PI * 2);
|
||||
cairo_stroke (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_edit (cairo_t *cr,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
int xborder = gtk_win32_get_sys_metric (GTK_WIN32_SYS_METRIC_CXBORDER);
|
||||
int yborder = gtk_win32_get_sys_metric (GTK_WIN32_SYS_METRIC_CYBORDER);
|
||||
|
||||
cairo_rectangle (cr, 0, 0, width, height);
|
||||
gtk_cairo_set_source_sys_color (cr, (state == 6 || state == 4) ? GTK_WIN32_SYS_COLOR_BTNFACE
|
||||
: GTK_WIN32_SYS_COLOR_WINDOW);
|
||||
cairo_fill_preserve (cr);
|
||||
|
||||
cairo_rectangle (cr, width - xborder, yborder,
|
||||
- (width - 2 * xborder), height - 2 * yborder);
|
||||
gtk_cairo_set_source_sys_color (cr, GTK_WIN32_SYS_COLOR_WINDOWFRAME);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_edit_noborder (cairo_t *cr,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
|
||||
cairo_rectangle (cr, 0, 0, width, height);
|
||||
gtk_cairo_set_source_sys_color (cr, (state == 6 || state == 4) ? GTK_WIN32_SYS_COLOR_BTNFACE
|
||||
: GTK_WIN32_SYS_COLOR_WINDOW);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_window (cairo_t *cr,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
draw_edge (cr, EDGE_RAISED, TRUE, 0, 0, width, height + 2);
|
||||
|
||||
gtk_cairo_set_source_sys_color (cr, state == 2 ? GTK_WIN32_SYS_COLOR_INACTIVECAPTION
|
||||
: GTK_WIN32_SYS_COLOR_ACTIVECAPTION);
|
||||
cairo_rectangle (cr, 2, 2, width - 4, height - 2);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_window_left (cairo_t *cr,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
draw_edge (cr, EDGE_RAISED, TRUE, 0, -2, width + 2, height + 4);
|
||||
|
||||
gtk_cairo_set_source_sys_color (cr, GTK_WIN32_SYS_COLOR_BTNFACE);
|
||||
cairo_rectangle (cr, 2, 0, width - 2, height);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_window_right (cairo_t *cr,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
draw_edge (cr, EDGE_RAISED, TRUE, -2, -2, width + 2, height + 4);
|
||||
|
||||
gtk_cairo_set_source_sys_color (cr, GTK_WIN32_SYS_COLOR_BTNFACE);
|
||||
cairo_rectangle (cr, 0, 0, width - 2, height);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_window_bottom (cairo_t *cr,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
draw_edge (cr, EDGE_RAISED, TRUE, 0, -2, width, height + 2);
|
||||
|
||||
gtk_cairo_set_source_sys_color (cr, GTK_WIN32_SYS_COLOR_BTNFACE);
|
||||
cairo_rectangle (cr, 2, 0, width - 4, height - 2);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_window_button (cairo_t *cr,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
Icon icon;
|
||||
|
||||
|
||||
switch (part)
|
||||
{
|
||||
case 15: /* minimize */
|
||||
icon = ICON_MINIMIZE;
|
||||
break;
|
||||
case 17: /* maximize */
|
||||
icon = ICON_MAXIMIZE;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
case 18: /* close */
|
||||
icon = ICON_CLOSE;
|
||||
break;
|
||||
case 21: /* restore */
|
||||
icon = ICON_RESTORE;
|
||||
break;
|
||||
}
|
||||
|
||||
draw_button (cr, 0, state, width, height);
|
||||
|
||||
gtk_cairo_set_source_sys_color (cr, state == 4 ? GTK_WIN32_SYS_COLOR_BTNSHADOW
|
||||
: GTK_WIN32_SYS_COLOR_BTNTEXT);
|
||||
mask_icon (cr, icon, 1, 1, width - 2, height - 2);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_tab_item (cairo_t *cr,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
draw_edge (cr, EDGE_RAISED, TRUE, 0, 0, width, height + 2);
|
||||
|
||||
gtk_cairo_set_source_sys_color (cr, GTK_WIN32_SYS_COLOR_BTNFACE);
|
||||
cairo_rectangle (cr, 2, 2, width - 4, height - 2);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_tab_pane (cairo_t *cr,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
draw_edge (cr, EDGE_RAISED, TRUE, 0, 0, width, height);
|
||||
|
||||
gtk_cairo_set_source_sys_color (cr, GTK_WIN32_SYS_COLOR_BTNFACE);
|
||||
cairo_rectangle (cr, 2, 2, width - 4, height - 4);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_tooltip (cairo_t *cr,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
int xborder = gtk_win32_get_sys_metric (GTK_WIN32_SYS_METRIC_CXDLGFRAME) -
|
||||
gtk_win32_get_sys_metric (GTK_WIN32_SYS_METRIC_CXEDGE);
|
||||
int yborder = gtk_win32_get_sys_metric (GTK_WIN32_SYS_METRIC_CYDLGFRAME) -
|
||||
gtk_win32_get_sys_metric (GTK_WIN32_SYS_METRIC_CYEDGE);
|
||||
|
||||
cairo_rectangle (cr, 0, 0, width, height);
|
||||
cairo_rectangle (cr, width - xborder, yborder,
|
||||
- (width - 2 * xborder), height - 2 * yborder);
|
||||
gtk_cairo_set_source_sys_color (cr, GTK_WIN32_SYS_COLOR_WINDOWFRAME);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
typedef struct _GtkWin32ThemePart GtkWin32ThemePart;
|
||||
struct _GtkWin32ThemePart {
|
||||
const char *class_name;
|
||||
gint part;
|
||||
gint size;
|
||||
GtkBorder margins;
|
||||
void (* draw_func) (cairo_t *cr,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height);
|
||||
};
|
||||
|
||||
static GtkWin32ThemePart theme_parts[] = {
|
||||
{ "button", 1, 0, { 3, 3, 3, 3 }, draw_button },
|
||||
{ "button", 2, 13, { 0, 0, 0, 0 }, draw_radio },
|
||||
{ "button", 3, 13, { 0, 0, 0, 0 }, draw_check },
|
||||
{ "button", 4, 0, { 3, 3, 3, 3 }, draw_frame },
|
||||
{ "edit", 1, 0, { 0, 0, 0, 0 }, draw_edit },
|
||||
{ "edit", 3, 0, { 0, 0, 0, 0 }, draw_edit_noborder },
|
||||
{ "edit", 6, 0, { 0, 0, 0, 0 }, draw_edit },
|
||||
{ "edit", 7, 0, { 0, 0, 0, 0 }, draw_edit },
|
||||
{ "edit", 8, 0, { 0, 0, 0, 0 }, draw_edit },
|
||||
{ "edit", 9, 0, { 0, 0, 0, 0 }, draw_edit },
|
||||
{ "tab", 1, 0, { 0, 0, 0, 0 }, draw_tab_item },
|
||||
{ "tab", 2, 0, { 0, 0, 0, 0 }, draw_tab_item },
|
||||
{ "tab", 3, 0, { 0, 0, 0, 0 }, draw_tab_item },
|
||||
{ "tab", 4, 0, { 0, 0, 0, 0 }, draw_tab_item },
|
||||
{ "tab", 5, 0, { 0, 0, 0, 0 }, draw_tab_item },
|
||||
{ "tab", 6, 0, { 0, 0, 0, 0 }, draw_tab_item },
|
||||
{ "tab", 7, 0, { 0, 0, 0, 0 }, draw_tab_item },
|
||||
{ "tab", 8, 0, { 0, 0, 0, 0 }, draw_tab_item },
|
||||
{ "tab", 9, 0, { 0, 0, 0, 0 }, draw_tab_pane },
|
||||
{ "tooltip", 1, 0, { 0, 0, 0, 0 }, draw_tooltip },
|
||||
{ "window", 1, 0, { 0, 0, 0, 0 }, draw_window },
|
||||
{ "window", 7, 0, { 0, 0, 0, 0 }, draw_window_left },
|
||||
{ "window", 8, 0, { 0, 0, 0, 0 }, draw_window_right },
|
||||
{ "window", 9, 0, { 0, 0, 0, 0 }, draw_window_bottom },
|
||||
{ "window", 15, 0, { 0, 0, 0, 0 }, draw_window_button },
|
||||
{ "window", 17, 0, { 0, 0, 0, 0 }, draw_window_button },
|
||||
{ "window", 18, 0, { 0, 0, 0, 0 }, draw_window_button },
|
||||
{ "window", 21, 0, { 0, 0, 0, 0 }, draw_window_button }
|
||||
};
|
||||
|
||||
static const GtkWin32ThemePart *
|
||||
get_theme_part (const char *class_name,
|
||||
gint part)
|
||||
{
|
||||
gsize i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (theme_parts); i++)
|
||||
{
|
||||
if (g_str_equal (theme_parts[i].class_name, class_name) &&
|
||||
theme_parts[i].part == part)
|
||||
return &theme_parts[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_win32_draw_theme_background (cairo_t *cr,
|
||||
const char *class_name,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
const GtkWin32ThemePart *theme_part;
|
||||
|
||||
theme_part = get_theme_part (class_name, part);
|
||||
|
||||
if (theme_part)
|
||||
{
|
||||
theme_part->draw_func (cr, part, state, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("No fallback code to draw background for class \"%s\", part %d", class_name, part);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_win32_get_theme_part_size (const char *class_name,
|
||||
int part,
|
||||
int state,
|
||||
int *width,
|
||||
int *height)
|
||||
{
|
||||
const GtkWin32ThemePart *theme_part;
|
||||
|
||||
theme_part = get_theme_part (class_name, part);
|
||||
|
||||
if (theme_part)
|
||||
{
|
||||
if (width)
|
||||
*width = theme_part->size;
|
||||
if (height)
|
||||
*height = theme_part->size;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (width)
|
||||
*width = 1;
|
||||
if (height)
|
||||
*height = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_win32_get_theme_margins (const char *class_name,
|
||||
int part,
|
||||
int state,
|
||||
GtkBorder *out_margins)
|
||||
{
|
||||
const GtkWin32ThemePart *theme_part;
|
||||
|
||||
theme_part = get_theme_part (class_name, part);
|
||||
|
||||
if (theme_part)
|
||||
{
|
||||
*out_margins = theme_part->margins;
|
||||
}
|
||||
else
|
||||
{
|
||||
out_margins->top = out_margins->bottom = out_margins->left = out_margins->right = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
FIXME_IMPLEMENT (int id)
|
||||
{
|
||||
g_warning ("win32 sys metric %d not implemented", id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct {
|
||||
const char *name;
|
||||
int value;
|
||||
int (* get_value) (int id);
|
||||
} win32_default_metrics[] = {
|
||||
{ "cxscreen", 0, FIXME_IMPLEMENT },
|
||||
{ "cyscreen", 0, FIXME_IMPLEMENT },
|
||||
{ "cxvscroll", 16, NULL },
|
||||
{ "cyhscroll", 16, NULL },
|
||||
{ "cycaption", 16, NULL },
|
||||
{ "cxborder", 1, NULL },
|
||||
{ "cyborder", 1, NULL },
|
||||
{ "cxdlgframe", 3, NULL },
|
||||
{ "cydlgframe", 3, NULL },
|
||||
{ "cyvthumb", 16, NULL },
|
||||
{ "cxhthumb", 16, NULL },
|
||||
{ "cxicon", 32, NULL },
|
||||
{ "cyicon", 32, NULL },
|
||||
{ "cxcursor", 32, NULL },
|
||||
{ "cycursor", 32, NULL },
|
||||
{ "cymenu", 19, NULL },
|
||||
{ "cxfullscreen", 0, FIXME_IMPLEMENT },
|
||||
{ "cyfullscreen", 0, FIXME_IMPLEMENT },
|
||||
{ "cykanjiwindow", 0, NULL },
|
||||
{ "mousepresent", 1, NULL },
|
||||
{ "cyvscroll", 16, NULL },
|
||||
{ "cxhscroll", 16, NULL },
|
||||
{ "debug", 0, NULL },
|
||||
{ "swapbutton", 0, NULL },
|
||||
{ "reserved1", 0, NULL },
|
||||
{ "reserved2", 0, NULL },
|
||||
{ "reserved3", 0, NULL },
|
||||
{ "reserved4", 0, NULL },
|
||||
{ "cxmin", 112, NULL },
|
||||
{ "cymin", 24, NULL },
|
||||
{ "cxsize", 18, NULL },
|
||||
{ "cysize", 15, NULL },
|
||||
{ "cxframe", 4, NULL },
|
||||
{ "cyframe", 4, NULL },
|
||||
{ "cxmintrack", 112, NULL },
|
||||
{ "cymintrack", 24, NULL },
|
||||
{ "cxdoubleclk", 0, FIXME_IMPLEMENT },
|
||||
{ "cydoubleclk", 0, FIXME_IMPLEMENT },
|
||||
{ "cxiconspacing", 75, NULL },
|
||||
{ "cyiconspacing", 75, NULL },
|
||||
{ "menudropalignment", 0, NULL },
|
||||
{ "penwindows", 0, NULL },
|
||||
{ "dbcsenabled", 1, NULL },
|
||||
{ "cmousebuttons", 3, NULL },
|
||||
{ "secure", 0, NULL },
|
||||
{ "cxedge", 2, NULL },
|
||||
{ "cyedge", 2, NULL },
|
||||
{ "cxminspacing", 160, NULL },
|
||||
{ "cyminspacing", 21, NULL },
|
||||
{ "cxsmicon", 16, NULL },
|
||||
{ "cysmicon", 16, NULL },
|
||||
{ "cysmcaption", 16, NULL },
|
||||
{ "cxsmsize", 15, NULL },
|
||||
{ "cysmsize", 15, NULL },
|
||||
{ "cxmenusize", 18, NULL },
|
||||
{ "cymenusize", 18, NULL },
|
||||
{ "arrange", 8, NULL },
|
||||
{ "cxminimized", 160, NULL },
|
||||
{ "cyminimized", 21, NULL },
|
||||
{ "cxmaxtrack", 0, FIXME_IMPLEMENT },
|
||||
{ "cymaxtrack", 0, FIXME_IMPLEMENT },
|
||||
{ "cxmaximized", 0, FIXME_IMPLEMENT },
|
||||
{ "cymaximized", 0, FIXME_IMPLEMENT },
|
||||
{ "network", 3, NULL },
|
||||
{ NULL, 0, NULL },
|
||||
{ NULL, 0, NULL },
|
||||
{ NULL, 0, NULL },
|
||||
{ "cleanboot", 0, NULL },
|
||||
{ "cxdrag", 4, NULL },
|
||||
{ "cydrag", 4, NULL },
|
||||
{ "showsounds", 0, NULL },
|
||||
{ "cxmenucheck", 13, NULL },
|
||||
{ "cymenucheck", 13, NULL },
|
||||
{ "slowmachine", 0, NULL },
|
||||
{ "mideastenabled", 0, NULL },
|
||||
{ "mousewheelpresent", 1, NULL },
|
||||
{ "xvirtualscreen", 0, FIXME_IMPLEMENT },
|
||||
{ "yvirtualscreen", 0, FIXME_IMPLEMENT },
|
||||
{ "cxvirtualscreen", 0, FIXME_IMPLEMENT },
|
||||
{ "cyvirtualscreen", 0, FIXME_IMPLEMENT },
|
||||
{ "cmonitors", 0, FIXME_IMPLEMENT },
|
||||
{ "samedisplayformat", 1, NULL },
|
||||
{ "immenabled", 1, NULL },
|
||||
{ "cxfocusborder", 1, NULL },
|
||||
{ "cyfocusborder", 1, NULL },
|
||||
{ NULL, 0, NULL },
|
||||
{ "tabletpc", 0, NULL },
|
||||
{ "mediacenter", 0, NULL },
|
||||
{ "starter", 0, NULL },
|
||||
{ "serverr2", 0, NULL },
|
||||
{ "cmetrics", 90, NULL },
|
||||
{ "mousehorizontalwheelpresent", 0, NULL },
|
||||
{ "cxpaddedborder", 0, NULL }
|
||||
};
|
||||
|
||||
const char *
|
||||
gtk_win32_get_sys_metric_name_for_id (gint id)
|
||||
{
|
||||
if (id >= 0 && id < G_N_ELEMENTS (win32_default_metrics))
|
||||
return win32_default_metrics[id].name;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
gtk_win32_get_sys_metric_id_for_name (const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (name != NULL, -1);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (win32_default_metrics); i++)
|
||||
{
|
||||
if (win32_default_metrics[i].name == NULL)
|
||||
continue;
|
||||
|
||||
if (g_str_equal (name, win32_default_metrics[i].name))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
gtk_win32_get_sys_metric (gint id)
|
||||
{
|
||||
if (id < 0 || id >= G_N_ELEMENTS (win32_default_metrics))
|
||||
return 0;
|
||||
|
||||
if (win32_default_metrics[id].get_value)
|
||||
return win32_default_metrics[id].get_value (id);
|
||||
|
||||
return win32_default_metrics[id].value;
|
||||
}
|
||||
|
||||
static struct {
|
||||
const char *name;
|
||||
GdkRGBA rgba;
|
||||
} win32_default_colors[] = {
|
||||
#define RGB(r, g, b) { (r)/255.0, (g)/255.0, (b)/255., 1.0 }
|
||||
{ "scrollbar", RGB(212, 208, 200) },
|
||||
{ "background", RGB(58, 110, 165) },
|
||||
{ "activecaption", RGB(10, 36, 106) },
|
||||
{ "inactivecaption", RGB(128, 128, 128) },
|
||||
{ "menu", RGB(212, 208, 200) },
|
||||
{ "window", RGB(255, 255, 255) },
|
||||
{ "windowframe", RGB(0, 0, 0) },
|
||||
{ "menutext", RGB(0, 0, 0) },
|
||||
{ "windowtext", RGB(0, 0, 0) },
|
||||
{ "captiontext", RGB(255, 255, 255) },
|
||||
{ "activeborder", RGB(212, 208, 200) },
|
||||
{ "inactiveborder", RGB(212, 208, 200) },
|
||||
{ "appworkspace", RGB(128, 128, 128) },
|
||||
{ "highlight", RGB(10, 36, 106) },
|
||||
{ "highlighttext", RGB(255, 255, 255) },
|
||||
{ "btnface", RGB(212, 208, 200) },
|
||||
{ "btnshadow", RGB(128, 128, 128) },
|
||||
{ "graytext", RGB(128, 128, 128) },
|
||||
{ "btntext", RGB(0, 0, 0) },
|
||||
{ "inactivecaptiontext", RGB(212, 208, 200) },
|
||||
{ "btnhighlight", RGB(255, 255, 255) },
|
||||
{ "3ddkshadow", RGB(64, 64, 64) },
|
||||
{ "3dlight", RGB(212, 208, 200) },
|
||||
{ "infotext", RGB(0, 0, 0) },
|
||||
{ "infobk", RGB(255, 255, 225) },
|
||||
{ "alternatebtnface", RGB(181, 181, 181) },
|
||||
{ "hotlight", RGB(0, 0, 200) },
|
||||
{ "gradientactivecaption", RGB(166, 202, 240) },
|
||||
{ "gradientinactivecaption", RGB(192, 192, 192) },
|
||||
{ "menuhilight", RGB(10, 36, 106) },
|
||||
{ "menubar", RGB(212, 208, 200) }
|
||||
#undef RGB
|
||||
};
|
||||
|
||||
const char *
|
||||
gtk_win32_get_sys_color_name_for_id (gint id)
|
||||
{
|
||||
if (id >= 0 && id < G_N_ELEMENTS (win32_default_colors))
|
||||
return win32_default_colors[id].name;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
gtk_win32_get_sys_color_id_for_name (const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (name != NULL, -1);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (win32_default_colors); i++)
|
||||
{
|
||||
if (g_str_equal (name, win32_default_colors[i].name))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_win32_get_sys_color (gint id,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
if (id < 0 || id >= G_N_ELEMENTS (win32_default_colors))
|
||||
{
|
||||
gdk_rgba_parse (color, "black");
|
||||
return;
|
||||
}
|
||||
|
||||
*color = win32_default_colors[id].rgba;
|
||||
}
|
||||
|
||||
@@ -1,181 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2016 Benjamin Otte <otte@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_WIN32_DRAW_H__
|
||||
#define __GTK_WIN32_DRAW_H__
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <cairo.h>
|
||||
|
||||
#include <gtk/gtkborder.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
enum {
|
||||
GTK_WIN32_SYS_COLOR_SCROLLBAR,
|
||||
GTK_WIN32_SYS_COLOR_BACKGROUND,
|
||||
GTK_WIN32_SYS_COLOR_ACTIVECAPTION,
|
||||
GTK_WIN32_SYS_COLOR_INACTIVECAPTION,
|
||||
GTK_WIN32_SYS_COLOR_MENU,
|
||||
GTK_WIN32_SYS_COLOR_WINDOW,
|
||||
GTK_WIN32_SYS_COLOR_WINDOWFRAME,
|
||||
GTK_WIN32_SYS_COLOR_MENUTEXT,
|
||||
GTK_WIN32_SYS_COLOR_WINDOWTEXT,
|
||||
GTK_WIN32_SYS_COLOR_CAPTIONTEXT,
|
||||
GTK_WIN32_SYS_COLOR_ACTIVEBORDER,
|
||||
GTK_WIN32_SYS_COLOR_INACTIVEBORDER,
|
||||
GTK_WIN32_SYS_COLOR_APPWORKSPACE,
|
||||
GTK_WIN32_SYS_COLOR_HIGHLIGHT,
|
||||
GTK_WIN32_SYS_COLOR_HIGHLIGHTTEXT,
|
||||
GTK_WIN32_SYS_COLOR_BTNFACE,
|
||||
GTK_WIN32_SYS_COLOR_BTNSHADOW,
|
||||
GTK_WIN32_SYS_COLOR_GRAYTEXT,
|
||||
GTK_WIN32_SYS_COLOR_BTNTEXT,
|
||||
GTK_WIN32_SYS_COLOR_INACTIVECAPTIONTEXT,
|
||||
GTK_WIN32_SYS_COLOR_BTNHIGHLIGHT,
|
||||
GTK_WIN32_SYS_COLOR_3DDKSHADOW,
|
||||
GTK_WIN32_SYS_COLOR_3DLIGHT,
|
||||
GTK_WIN32_SYS_COLOR_INFOTEXT,
|
||||
GTK_WIN32_SYS_COLOR_INFOBK,
|
||||
GTK_WIN32_SYS_COLOR_ALTERNATEBTNFACE,
|
||||
GTK_WIN32_SYS_COLOR_HOTLIGHT,
|
||||
GTK_WIN32_SYS_COLOR_GRADIENTACTIVECAPTION,
|
||||
GTK_WIN32_SYS_COLOR_GRADIENTINACTIVECAPTION,
|
||||
GTK_WIN32_SYS_COLOR_MENUHILIGHT,
|
||||
GTK_WIN32_SYS_COLOR_MENUBAR
|
||||
};
|
||||
|
||||
enum {
|
||||
GTK_WIN32_SYS_METRIC_CXSCREEN = 0,
|
||||
GTK_WIN32_SYS_METRIC_CYSCREEN = 1,
|
||||
GTK_WIN32_SYS_METRIC_CXVSCROLL = 2,
|
||||
GTK_WIN32_SYS_METRIC_CYHSCROLL = 3,
|
||||
GTK_WIN32_SYS_METRIC_CYCAPTION = 4,
|
||||
GTK_WIN32_SYS_METRIC_CXBORDER = 5,
|
||||
GTK_WIN32_SYS_METRIC_CYBORDER = 6,
|
||||
GTK_WIN32_SYS_METRIC_CXDLGFRAME = 7,
|
||||
GTK_WIN32_SYS_METRIC_CYDLGFRAME = 8,
|
||||
GTK_WIN32_SYS_METRIC_CYVTHUMB = 9,
|
||||
GTK_WIN32_SYS_METRIC_CXHTHUMB = 10,
|
||||
GTK_WIN32_SYS_METRIC_CXICON = 11,
|
||||
GTK_WIN32_SYS_METRIC_CYICON = 12,
|
||||
GTK_WIN32_SYS_METRIC_CXCURSOR = 13,
|
||||
GTK_WIN32_SYS_METRIC_CYCURSOR = 14,
|
||||
GTK_WIN32_SYS_METRIC_CYMENU = 15,
|
||||
GTK_WIN32_SYS_METRIC_CXFULLSCREEN = 16,
|
||||
GTK_WIN32_SYS_METRIC_CYFULLSCREEN = 17,
|
||||
GTK_WIN32_SYS_METRIC_CYKANJIWINDOW = 18,
|
||||
GTK_WIN32_SYS_METRIC_MOUSEPRESENT = 19,
|
||||
GTK_WIN32_SYS_METRIC_CYVSCROLL = 20,
|
||||
GTK_WIN32_SYS_METRIC_CXHSCROLL = 21,
|
||||
GTK_WIN32_SYS_METRIC_DEBUG = 22,
|
||||
GTK_WIN32_SYS_METRIC_SWAPBUTTON = 23,
|
||||
GTK_WIN32_SYS_METRIC_RESERVED1 = 24,
|
||||
GTK_WIN32_SYS_METRIC_RESERVED2 = 25,
|
||||
GTK_WIN32_SYS_METRIC_RESERVED3 = 26,
|
||||
GTK_WIN32_SYS_METRIC_RESERVED4 = 27,
|
||||
GTK_WIN32_SYS_METRIC_CXMIN = 28,
|
||||
GTK_WIN32_SYS_METRIC_CYMIN = 29,
|
||||
GTK_WIN32_SYS_METRIC_CXSIZE = 30,
|
||||
GTK_WIN32_SYS_METRIC_CYSIZE = 31,
|
||||
GTK_WIN32_SYS_METRIC_CXFRAME = 32,
|
||||
GTK_WIN32_SYS_METRIC_CYFRAME = 33,
|
||||
GTK_WIN32_SYS_METRIC_CXMINTRACK = 34,
|
||||
GTK_WIN32_SYS_METRIC_CYMINTRACK = 35,
|
||||
GTK_WIN32_SYS_METRIC_CXDOUBLECLK = 36,
|
||||
GTK_WIN32_SYS_METRIC_CYDOUBLECLK = 37,
|
||||
GTK_WIN32_SYS_METRIC_CXICONSPACING = 38,
|
||||
GTK_WIN32_SYS_METRIC_CYICONSPACING = 39,
|
||||
GTK_WIN32_SYS_METRIC_MENUDROPALIGNMENT = 40,
|
||||
GTK_WIN32_SYS_METRIC_PENWINDOWS = 41,
|
||||
GTK_WIN32_SYS_METRIC_DBCSENABLED = 42,
|
||||
GTK_WIN32_SYS_METRIC_CMOUSEBUTTONS = 43,
|
||||
GTK_WIN32_SYS_METRIC_SECURE = 44,
|
||||
GTK_WIN32_SYS_METRIC_CXEDGE = 45,
|
||||
GTK_WIN32_SYS_METRIC_CYEDGE = 46,
|
||||
GTK_WIN32_SYS_METRIC_CXMINSPACING = 47,
|
||||
GTK_WIN32_SYS_METRIC_CYMINSPACING = 48,
|
||||
GTK_WIN32_SYS_METRIC_CXSMICON = 49,
|
||||
GTK_WIN32_SYS_METRIC_CYSMICON = 50,
|
||||
GTK_WIN32_SYS_METRIC_CYSMCAPTION = 51,
|
||||
GTK_WIN32_SYS_METRIC_CXSMSIZE = 52,
|
||||
GTK_WIN32_SYS_METRIC_CYSMSIZE = 53,
|
||||
GTK_WIN32_SYS_METRIC_CXMENUSIZE = 54,
|
||||
GTK_WIN32_SYS_METRIC_CYMENUSIZE = 55,
|
||||
GTK_WIN32_SYS_METRIC_ARRANGE = 56,
|
||||
GTK_WIN32_SYS_METRIC_CXMINIMIZED = 57,
|
||||
GTK_WIN32_SYS_METRIC_CYMINIMIZED = 58,
|
||||
GTK_WIN32_SYS_METRIC_CXMAXTRACK = 59,
|
||||
GTK_WIN32_SYS_METRIC_CYMAXTRACK = 60,
|
||||
GTK_WIN32_SYS_METRIC_CXMAXIMIZED = 61,
|
||||
GTK_WIN32_SYS_METRIC_CYMAXIMIZED = 62,
|
||||
GTK_WIN32_SYS_METRIC_NETWORK = 63,
|
||||
GTK_WIN32_SYS_METRIC_CLEANBOOT = 67,
|
||||
GTK_WIN32_SYS_METRIC_CXDRAG = 68,
|
||||
GTK_WIN32_SYS_METRIC_CYDRAG = 69,
|
||||
GTK_WIN32_SYS_METRIC_SHOWSOUNDS = 70,
|
||||
GTK_WIN32_SYS_METRIC_CXMENUCHECK = 71,
|
||||
GTK_WIN32_SYS_METRIC_CYMENUCHECK = 72,
|
||||
GTK_WIN32_SYS_METRIC_SLOWMACHINE = 73,
|
||||
GTK_WIN32_SYS_METRIC_MIDEASTENABLED = 74,
|
||||
GTK_WIN32_SYS_METRIC_MOUSEWHEELPRESENT = 75,
|
||||
GTK_WIN32_SYS_METRIC_XVIRTUALSCREEN = 76,
|
||||
GTK_WIN32_SYS_METRIC_YVIRTUALSCREEN = 77,
|
||||
GTK_WIN32_SYS_METRIC_CXVIRTUALSCREEN = 78,
|
||||
GTK_WIN32_SYS_METRIC_CYVIRTUALSCREEN = 79,
|
||||
GTK_WIN32_SYS_METRIC_CMONITORS = 80,
|
||||
GTK_WIN32_SYS_METRIC_SAMEDISPLAYFORMAT = 81,
|
||||
GTK_WIN32_SYS_METRIC_IMMENABLED = 82,
|
||||
GTK_WIN32_SYS_METRIC_CXFOCUSBORDER = 83,
|
||||
GTK_WIN32_SYS_METRIC_CYFOCUSBORDER = 84,
|
||||
GTK_WIN32_SYS_METRIC_TABLETPC = 86,
|
||||
GTK_WIN32_SYS_METRIC_MEDIACENTER = 87,
|
||||
GTK_WIN32_SYS_METRIC_STARTER = 88,
|
||||
GTK_WIN32_SYS_METRIC_SERVERR2 = 89,
|
||||
GTK_WIN32_SYS_METRIC_CMETRICS = 90,
|
||||
GTK_WIN32_SYS_METRIC_MOUSEHORIZONTALWHEELPRESENT = 91,
|
||||
GTK_WIN32_SYS_METRIC_CXPADDEDBORDER = 92
|
||||
};
|
||||
|
||||
void gtk_win32_draw_theme_background (cairo_t *cr,
|
||||
const char *class_name,
|
||||
int part,
|
||||
int state,
|
||||
int width,
|
||||
int height);
|
||||
void gtk_win32_get_theme_part_size (const char *class_name,
|
||||
int part,
|
||||
int state,
|
||||
int *width,
|
||||
int *height);
|
||||
void gtk_win32_get_theme_margins (const char *class_name,
|
||||
int part,
|
||||
int state,
|
||||
GtkBorder *out_margins);
|
||||
|
||||
const char * gtk_win32_get_sys_metric_name_for_id (gint id);
|
||||
int gtk_win32_get_sys_metric_id_for_name (const char *name);
|
||||
int gtk_win32_get_sys_metric (gint id);
|
||||
|
||||
const char * gtk_win32_get_sys_color_name_for_id (gint id);
|
||||
int gtk_win32_get_sys_color_id_for_name (const char *name);
|
||||
void gtk_win32_get_sys_color (gint id,
|
||||
GdkRGBA *color);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_WIN32_DRAW_H__ */
|
||||
@@ -1,518 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* Authors: Carlos Garnacho <carlosg@gnome.org>
|
||||
* Cosimo Cecchi <cosimoc@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "gtkwin32themeprivate.h"
|
||||
|
||||
#include "gtkwin32drawprivate.h"
|
||||
|
||||
#include "gdk/gdk-private.h"
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
||||
#include <windows.h>
|
||||
#include <gdk/win32/gdkwin32.h>
|
||||
#include <cairo-win32.h>
|
||||
|
||||
typedef HANDLE HTHEME;
|
||||
|
||||
#define UXTHEME_DLL "uxtheme.dll"
|
||||
|
||||
static HINSTANCE uxtheme_dll = NULL;
|
||||
static gboolean use_xp_theme = FALSE;
|
||||
|
||||
typedef HRESULT (FAR PASCAL *GetThemeSysFontFunc) (HTHEME hTheme, int iFontID, OUT LOGFONTW *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);
|
||||
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);
|
||||
typedef BOOL (FAR PASCAL *IsThemeActiveFunc) (VOID);
|
||||
typedef BOOL (FAR PASCAL *IsAppThemedFunc) (VOID);
|
||||
typedef BOOL (FAR PASCAL *IsThemeBackgroundPartiallyTransparentFunc) (HTHEME hTheme,
|
||||
int iPartId,
|
||||
int iStateId);
|
||||
typedef HRESULT (FAR PASCAL *DrawThemeParentBackgroundFunc) (HWND hwnd,
|
||||
HDC hdc,
|
||||
RECT *prc);
|
||||
typedef HRESULT (FAR PASCAL *GetThemePartSizeFunc) (HTHEME hTheme,
|
||||
HDC hdc,
|
||||
int iPartId,
|
||||
int iStateId,
|
||||
RECT *prc,
|
||||
int eSize,
|
||||
SIZE *psz);
|
||||
typedef HRESULT (FAR PASCAL *GetThemeBackgroundExtentFunc) (HTHEME hTheme,
|
||||
HDC hdc,
|
||||
int iPartId,
|
||||
int iStateId,
|
||||
const RECT *pContentRect,
|
||||
RECT *pExtentRect);
|
||||
|
||||
static GetThemeSysFontFunc get_theme_sys_font = NULL;
|
||||
static GetThemeSysColorFunc GetThemeSysColor = NULL;
|
||||
static GetThemeSysSizeFunc GetThemeSysSize = NULL;
|
||||
static OpenThemeDataFunc OpenThemeData = NULL;
|
||||
static CloseThemeDataFunc CloseThemeData = NULL;
|
||||
static DrawThemeBackgroundFunc draw_theme_background = NULL;
|
||||
static EnableThemeDialogTextureFunc enable_theme_dialog_texture = NULL;
|
||||
static IsThemeActiveFunc is_theme_active = NULL;
|
||||
static IsAppThemedFunc is_app_themed = NULL;
|
||||
static IsThemeBackgroundPartiallyTransparentFunc is_theme_partially_transparent = NULL;
|
||||
static DrawThemeParentBackgroundFunc draw_theme_parent_background = NULL;
|
||||
static GetThemePartSizeFunc GetThemePartSize = NULL;
|
||||
static GetThemeBackgroundExtentFunc GetThemeBackgroundExtent = NULL;
|
||||
|
||||
#endif
|
||||
|
||||
static GHashTable *themes_by_class = NULL;
|
||||
|
||||
struct _GtkWin32Theme {
|
||||
char *class_name;
|
||||
gint ref_count;
|
||||
#ifdef G_OS_WIN32
|
||||
HTHEME htheme;
|
||||
#endif
|
||||
};
|
||||
|
||||
GtkWin32Theme *
|
||||
gtk_win32_theme_ref (GtkWin32Theme *theme)
|
||||
{
|
||||
theme->ref_count++;
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_win32_theme_close (GtkWin32Theme *theme)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
if (theme->htheme)
|
||||
{
|
||||
CloseThemeData (theme->htheme);
|
||||
theme->htheme = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_win32_theme_unref (GtkWin32Theme *theme)
|
||||
{
|
||||
theme->ref_count--;
|
||||
|
||||
if (theme->ref_count > 0)
|
||||
return;
|
||||
|
||||
g_hash_table_remove (themes_by_class, theme->class_name);
|
||||
|
||||
gtk_win32_theme_close (theme);
|
||||
g_free (theme->class_name);
|
||||
|
||||
g_slice_free (GtkWin32Theme, theme);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_win32_theme_equal (GtkWin32Theme *theme1,
|
||||
GtkWin32Theme *theme2)
|
||||
{
|
||||
/* Themes are cached so they're guaranteed unique. */
|
||||
return theme1 == theme2;
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
||||
static GdkWin32MessageFilterReturn
|
||||
invalidate_win32_themes (GdkWin32Display *display,
|
||||
MSG *msg,
|
||||
gint *ret_valp,
|
||||
gpointer data)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
gboolean theme_was_open = FALSE;
|
||||
gpointer theme;
|
||||
|
||||
if (msg->message != WM_THEMECHANGED)
|
||||
return GDK_WIN32_MESSAGE_FILTER_CONTINUE;
|
||||
|
||||
g_hash_table_iter_init (&iter, themes_by_class);
|
||||
while (g_hash_table_iter_next (&iter, NULL, &theme))
|
||||
{
|
||||
theme_was_open |= gtk_win32_theme_close (theme);
|
||||
}
|
||||
if (theme_was_open)
|
||||
gtk_style_context_reset_widgets (display);
|
||||
|
||||
return GDK_WIN32_MESSAGE_FILTER_CONTINUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_win32_theme_init (void)
|
||||
{
|
||||
char *buf;
|
||||
char dummy;
|
||||
int n, k;
|
||||
|
||||
if (uxtheme_dll)
|
||||
return;
|
||||
|
||||
n = GetSystemDirectory (&dummy, 0);
|
||||
if (n <= 0)
|
||||
return;
|
||||
|
||||
buf = g_malloc (n + 1 + strlen (UXTHEME_DLL));
|
||||
k = GetSystemDirectory (buf, n);
|
||||
if (k == 0 || k > n)
|
||||
{
|
||||
g_free (buf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!G_IS_DIR_SEPARATOR (buf[strlen (buf) -1]))
|
||||
strcat (buf, G_DIR_SEPARATOR_S);
|
||||
strcat (buf, UXTHEME_DLL);
|
||||
|
||||
uxtheme_dll = LoadLibrary (buf);
|
||||
g_free (buf);
|
||||
|
||||
if (!uxtheme_dll)
|
||||
return;
|
||||
|
||||
is_app_themed = (IsAppThemedFunc) GetProcAddress (uxtheme_dll, "IsAppThemed");
|
||||
if (is_app_themed)
|
||||
{
|
||||
is_theme_active = (IsThemeActiveFunc) GetProcAddress (uxtheme_dll, "IsThemeActive");
|
||||
OpenThemeData = (OpenThemeDataFunc) GetProcAddress (uxtheme_dll, "OpenThemeData");
|
||||
CloseThemeData = (CloseThemeDataFunc) GetProcAddress (uxtheme_dll, "CloseThemeData");
|
||||
draw_theme_background = (DrawThemeBackgroundFunc) GetProcAddress (uxtheme_dll, "DrawThemeBackground");
|
||||
enable_theme_dialog_texture = (EnableThemeDialogTextureFunc) GetProcAddress (uxtheme_dll, "EnableThemeDialogTexture");
|
||||
get_theme_sys_font = (GetThemeSysFontFunc) GetProcAddress (uxtheme_dll, "GetThemeSysFont");
|
||||
GetThemeSysColor = (GetThemeSysColorFunc) GetProcAddress (uxtheme_dll, "GetThemeSysColor");
|
||||
GetThemeSysSize = (GetThemeSysSizeFunc) GetProcAddress (uxtheme_dll, "GetThemeSysSize");
|
||||
is_theme_partially_transparent = (IsThemeBackgroundPartiallyTransparentFunc) GetProcAddress (uxtheme_dll, "IsThemeBackgroundPartiallyTransparent");
|
||||
draw_theme_parent_background = (DrawThemeParentBackgroundFunc) GetProcAddress (uxtheme_dll, "DrawThemeParentBackground");
|
||||
GetThemePartSize = (GetThemePartSizeFunc) GetProcAddress (uxtheme_dll, "GetThemePartSize");
|
||||
GetThemeBackgroundExtent = (GetThemeBackgroundExtentFunc) GetProcAddress (uxtheme_dll, "GetThemeBackgroundExtent");
|
||||
}
|
||||
|
||||
if (is_app_themed && is_theme_active)
|
||||
{
|
||||
use_xp_theme = (is_app_themed () && is_theme_active ());
|
||||
}
|
||||
else
|
||||
{
|
||||
use_xp_theme = FALSE;
|
||||
}
|
||||
|
||||
gdk_win32_display_add_filter (gdk_display_get_default (), invalidate_win32_themes, NULL);
|
||||
}
|
||||
|
||||
static HTHEME
|
||||
gtk_win32_theme_get_htheme (GtkWin32Theme *theme)
|
||||
{
|
||||
guint16 *wclass;
|
||||
|
||||
gtk_win32_theme_init ();
|
||||
|
||||
if (theme->htheme)
|
||||
return theme->htheme;
|
||||
|
||||
wclass = g_utf8_to_utf16 (theme->class_name, -1, NULL, NULL, NULL);
|
||||
theme->htheme = OpenThemeData (NULL, wclass);
|
||||
g_free (wclass);
|
||||
|
||||
return theme->htheme;
|
||||
}
|
||||
|
||||
#endif /* G_OS_WIN32 */
|
||||
|
||||
static char *
|
||||
canonicalize_class_name (const char *classname)
|
||||
{
|
||||
/* Wine claims class names are case insensitive, so we convert them
|
||||
here to avoid multiple theme objects referencing the same HTHEME. */
|
||||
return g_ascii_strdown (classname, -1);
|
||||
}
|
||||
|
||||
GtkWin32Theme *
|
||||
gtk_win32_theme_lookup (const char *classname)
|
||||
{
|
||||
GtkWin32Theme *theme;
|
||||
char *canonical_classname;
|
||||
|
||||
if (G_UNLIKELY (themes_by_class == NULL))
|
||||
themes_by_class = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
canonical_classname = canonicalize_class_name (classname);
|
||||
theme = g_hash_table_lookup (themes_by_class, canonical_classname);
|
||||
|
||||
if (theme != NULL)
|
||||
{
|
||||
g_free (canonical_classname);
|
||||
return gtk_win32_theme_ref (theme);
|
||||
}
|
||||
|
||||
theme = g_slice_new0 (GtkWin32Theme);
|
||||
theme->ref_count = 1;
|
||||
theme->class_name = canonical_classname;
|
||||
|
||||
g_hash_table_insert (themes_by_class, theme->class_name, theme);
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
GtkWin32Theme *
|
||||
gtk_win32_theme_parse (GtkCssParser *parser)
|
||||
{
|
||||
GtkWin32Theme *theme;
|
||||
char *class_name;
|
||||
|
||||
class_name = _gtk_css_parser_try_name (parser, TRUE);
|
||||
if (class_name == NULL)
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected valid win32 theme name");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
theme = gtk_win32_theme_lookup (class_name);
|
||||
g_free (class_name);
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
gtk_win32_theme_create_surface (GtkWin32Theme *theme,
|
||||
int xp_part,
|
||||
int state,
|
||||
int margins[4],
|
||||
int width,
|
||||
int height,
|
||||
int *x_offs_out,
|
||||
int *y_offs_out)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
int x_offs;
|
||||
int y_offs;
|
||||
#ifdef G_OS_WIN32
|
||||
gboolean has_alpha;
|
||||
HDC hdc;
|
||||
RECT rect;
|
||||
SIZE size;
|
||||
HRESULT res;
|
||||
HTHEME htheme;
|
||||
#endif
|
||||
|
||||
x_offs = margins[3];
|
||||
y_offs = margins[0];
|
||||
|
||||
width -= margins[3] + margins[1];
|
||||
height -= margins[0] + margins[2];
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
htheme = gtk_win32_theme_get_htheme (theme);
|
||||
if (htheme)
|
||||
{
|
||||
rect.left = 0;
|
||||
rect.top = 0;
|
||||
rect.right = width;
|
||||
rect.bottom = height;
|
||||
|
||||
hdc = GetDC (NULL);
|
||||
res = GetThemePartSize (htheme, hdc, xp_part, state, &rect, 2 /*TS_DRAW*/, &size);
|
||||
ReleaseDC (NULL, hdc);
|
||||
|
||||
if (res == S_OK)
|
||||
{
|
||||
x_offs += (width - size.cx) / 2;
|
||||
y_offs += (height - size.cy) / 2;
|
||||
|
||||
width = size.cx;
|
||||
height = size.cy;
|
||||
|
||||
rect.right = width;
|
||||
rect.bottom = height;
|
||||
}
|
||||
|
||||
has_alpha = is_theme_partially_transparent (htheme, 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 (htheme, hdc, xp_part, state, &rect, &rect);
|
||||
|
||||
*x_offs_out = x_offs;
|
||||
*y_offs_out = y_offs;
|
||||
|
||||
if (res == S_OK)
|
||||
return surface;
|
||||
}
|
||||
else
|
||||
#endif /* G_OS_WIN32 */
|
||||
{
|
||||
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
|
||||
}
|
||||
|
||||
cr = cairo_create (surface);
|
||||
|
||||
gtk_win32_draw_theme_background (cr, theme->class_name, xp_part, state, width, height);
|
||||
|
||||
cairo_destroy (cr);
|
||||
|
||||
*x_offs_out = x_offs;
|
||||
*y_offs_out = y_offs;
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_win32_theme_get_part_border (GtkWin32Theme *theme,
|
||||
int part,
|
||||
int state,
|
||||
GtkBorder *out_border)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
HTHEME htheme = gtk_win32_theme_get_htheme (theme);
|
||||
RECT content, extent;
|
||||
HDC hdc;
|
||||
HRESULT res;
|
||||
|
||||
if (use_xp_theme && GetThemeBackgroundExtent != NULL && htheme != NULL)
|
||||
{
|
||||
/* According to Wine source code, these values don't matter
|
||||
* because uxtheme.dll deals with margins internally. */
|
||||
content.left = content.top = 0;
|
||||
content.right = content.bottom = 100;
|
||||
|
||||
hdc = GetDC (NULL);
|
||||
res = GetThemeBackgroundExtent (htheme, hdc, part, state, &content, &extent);
|
||||
ReleaseDC (NULL, hdc);
|
||||
|
||||
if (SUCCEEDED (res))
|
||||
{
|
||||
out_border->top = content.top - extent.top;
|
||||
out_border->left = content.left - extent.left;
|
||||
out_border->bottom = extent.bottom - content.bottom;
|
||||
out_border->right = extent.right - content.right;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
gtk_win32_get_theme_margins (theme->class_name, part, state, out_border);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_win32_theme_get_part_size (GtkWin32Theme *theme,
|
||||
int part,
|
||||
int state,
|
||||
int *width,
|
||||
int *height)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
HTHEME htheme = gtk_win32_theme_get_htheme (theme);
|
||||
SIZE size;
|
||||
HRESULT res;
|
||||
|
||||
if (use_xp_theme && GetThemePartSize != NULL && htheme != NULL)
|
||||
{
|
||||
res = GetThemePartSize (htheme, NULL, part, state, NULL, 1 /* TS_TRUE */, &size);
|
||||
|
||||
if (SUCCEEDED (res))
|
||||
{
|
||||
if (width)
|
||||
*width = size.cx;
|
||||
if (height)
|
||||
*height = size.cy;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
gtk_win32_get_theme_part_size (theme->class_name, part, state, width, height);
|
||||
}
|
||||
|
||||
int
|
||||
gtk_win32_theme_get_size (GtkWin32Theme *theme,
|
||||
int id)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
if (use_xp_theme && GetThemeSysSize != NULL)
|
||||
{
|
||||
HTHEME htheme = gtk_win32_theme_get_htheme (theme);
|
||||
int size;
|
||||
|
||||
/* If htheme is NULL it will just return the GetSystemMetrics value */
|
||||
size = GetThemeSysSize (htheme, id);
|
||||
/* fall through on invalid parameter */
|
||||
if (GetLastError () == 0)
|
||||
return size;
|
||||
}
|
||||
|
||||
return GetSystemMetrics (id);
|
||||
#else
|
||||
return gtk_win32_get_sys_metric (id);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
gtk_win32_theme_get_color (GtkWin32Theme *theme,
|
||||
gint id,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
HTHEME htheme;
|
||||
DWORD dcolor;
|
||||
|
||||
if (use_xp_theme && GetThemeSysColor != NULL)
|
||||
{
|
||||
htheme = gtk_win32_theme_get_htheme (theme);
|
||||
|
||||
/* if htheme is NULL, it will just return the GetSysColor() value */
|
||||
dcolor = GetThemeSysColor (htheme, id);
|
||||
}
|
||||
else
|
||||
dcolor = GetSysColor (id);
|
||||
|
||||
color->alpha = 1.0;
|
||||
color->red = GetRValue (dcolor) / 255.0;
|
||||
color->green = GetGValue (dcolor) / 255.0;
|
||||
color->blue = GetBValue (dcolor) / 255.0;
|
||||
#else
|
||||
gtk_win32_get_sys_color (id, color);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
gtk_win32_theme_print (GtkWin32Theme *theme,
|
||||
GString *string)
|
||||
{
|
||||
g_string_append (string, theme->class_name);
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* Authors: Alexander Larsson <alexl@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_WIN32_THEME_PART_H__
|
||||
#define __GTK_WIN32_THEME_PART_H__
|
||||
|
||||
#include "gtkborder.h"
|
||||
#include "gtkcssparserprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkWin32Theme GtkWin32Theme;
|
||||
|
||||
#define GTK_WIN32_THEME_SYMBOLIC_COLOR_NAME "-gtk-win32-color"
|
||||
|
||||
GtkWin32Theme * gtk_win32_theme_lookup (const char *class_name);
|
||||
GtkWin32Theme * gtk_win32_theme_parse (GtkCssParser *parser);
|
||||
|
||||
GtkWin32Theme * gtk_win32_theme_ref (GtkWin32Theme *theme);
|
||||
void gtk_win32_theme_unref (GtkWin32Theme *theme);
|
||||
|
||||
gboolean gtk_win32_theme_equal (GtkWin32Theme *theme1,
|
||||
GtkWin32Theme *theme2);
|
||||
|
||||
void gtk_win32_theme_print (GtkWin32Theme *theme,
|
||||
GString *string);
|
||||
|
||||
cairo_surface_t * gtk_win32_theme_create_surface (GtkWin32Theme *theme,
|
||||
int xp_part,
|
||||
int state,
|
||||
int margins[4],
|
||||
int width,
|
||||
int height,
|
||||
int *x_offs_out,
|
||||
int *y_offs_out);
|
||||
|
||||
void gtk_win32_theme_get_part_border (GtkWin32Theme *theme,
|
||||
int part,
|
||||
int state,
|
||||
GtkBorder *out_border);
|
||||
void gtk_win32_theme_get_part_size (GtkWin32Theme *theme,
|
||||
int part,
|
||||
int state,
|
||||
int *width,
|
||||
int *height);
|
||||
int gtk_win32_theme_get_size (GtkWin32Theme *theme,
|
||||
int id);
|
||||
void gtk_win32_theme_get_color (GtkWin32Theme *theme,
|
||||
gint id,
|
||||
GdkRGBA *color);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_WIN32_THEME_PART_H__ */
|
||||
@@ -65,7 +65,6 @@ gtk_private_sources = files([
|
||||
'gtkcssimagescaled.c',
|
||||
'gtkcssimageurl.c',
|
||||
'gtkcssimagevalue.c',
|
||||
'gtkcssimagewin32.c',
|
||||
'gtkcssinheritvalue.c',
|
||||
'gtkcssinitialvalue.c',
|
||||
'gtkcsskeyframes.c',
|
||||
@@ -99,7 +98,6 @@ gtk_private_sources = files([
|
||||
'gtkcssunsetvalue.c',
|
||||
'gtkcssvalue.c',
|
||||
'gtkcsswidgetnode.c',
|
||||
'gtkcsswin32sizevalue.c',
|
||||
'gtkfilechooserembed.c',
|
||||
'gtkfilechooserentry.c',
|
||||
'gtkfilechoosererrorstack.c',
|
||||
@@ -144,9 +142,6 @@ gtk_private_sources = files([
|
||||
'gtktextbtree.c',
|
||||
'gtktrashmonitor.c',
|
||||
'gtktreedatalist.c',
|
||||
'gtkwin32draw.c',
|
||||
'gtkwin32theme.c',
|
||||
'gtkwin32theme.c',
|
||||
])
|
||||
|
||||
# List of files that contain public API, and should be introspected
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,251 +0,0 @@
|
||||
@import url("gtk-win32-base.css");
|
||||
|
||||
/* Menus */
|
||||
|
||||
menubar {
|
||||
background-color: transparent;
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(menu, 7, 1);
|
||||
}
|
||||
|
||||
menubar > menuitem {
|
||||
background-color: transparent;
|
||||
border-width: 0;
|
||||
background-image: -gtk-win32-theme-part(menu, 8, 1);
|
||||
}
|
||||
|
||||
menubar > menuitem:hover {
|
||||
background-image: -gtk-win32-theme-part(menu, 8, 3);
|
||||
}
|
||||
|
||||
menuitem:hover {
|
||||
background-image: -gtk-win32-theme-part(menu, 14, 2);
|
||||
}
|
||||
|
||||
menuitem:hover:disabled {
|
||||
background-image: -gtk-win32-theme-part(menu, 14, 4);
|
||||
}
|
||||
|
||||
menuitem radio,
|
||||
menuitem radio:hover,
|
||||
menuitem radio:disabled {
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
menuitem radio:active,
|
||||
menuitem radio:active:hover {
|
||||
background-image: -gtk-win32-theme-part(menu, 11, 3);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
menuitem radio:indeterminate,
|
||||
menuitem radio:indeterminate:disabled,
|
||||
menuitem radio:indeterminate:hover,
|
||||
menuitem radio:indeterminate:active,
|
||||
menuitem radio:indeterminate:active:hover {
|
||||
background-image: none; /* Fall back to default, this state is not in win32 */
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
menuitem radio:disabled:active,
|
||||
menuitem radio:disabled:active:hover {
|
||||
background-image: -gtk-win32-theme-part(menu, 11, 4);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
menuitem check,
|
||||
menuitem check:hover,
|
||||
menuitem check:disabled {
|
||||
background-image: none;
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
menuitem check:active,
|
||||
menuitem check:active:hover {
|
||||
background-image: -gtk-win32-theme-part(menu, 11, 1);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
menuitem check:indeterminate,
|
||||
menuitem check:indeterminate:disabled,
|
||||
menuitem check:indeterminate:hover,
|
||||
menuitem check:indeterminate:active,
|
||||
menuitem check:indeterminate:active:hover {
|
||||
background-image: none; /* Fall back to default, this state is not in win32 */
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
menuitem check:disabled:active,
|
||||
menuitem check:disabled:active:hover{
|
||||
background-image: -gtk-win32-theme-part(menu, 11, 2);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
/* Listbox */
|
||||
|
||||
/* We're cheating here, using part 6 (listview header group),
|
||||
because part 1 (listview item) is empty for some reason */
|
||||
row:hover {
|
||||
background-image: -gtk-win32-theme-part(listview, 6, 10);
|
||||
}
|
||||
|
||||
row:selected {
|
||||
background-color: transparent;
|
||||
/* Override *:selected {} blanket style, keeping the background - bright
|
||||
and the text - dark */
|
||||
color: @text_color;
|
||||
background-image: -gtk-win32-theme-part(listview, 6, 13);
|
||||
}
|
||||
|
||||
row:selected:focus {
|
||||
background-image: -gtk-win32-theme-part(listview, 6, 11);
|
||||
}
|
||||
|
||||
row:selected:hover {
|
||||
background-image: -gtk-win32-theme-part(listview, 6, 12);
|
||||
}
|
||||
|
||||
/* Titlebar */
|
||||
|
||||
decoration {
|
||||
padding: calc(-gtk-win32-size(window, cyframe) + -gtk-win32-size(window, cxpaddedborder))
|
||||
calc(-gtk-win32-size(window, cxframe) + -gtk-win32-size(window, cxpaddedborder));
|
||||
background-image: -gtk-win32-theme-part(window, 1, 1),
|
||||
-gtk-win32-theme-part(window, 9, 1),
|
||||
-gtk-win32-theme-part(window, 7, 1),
|
||||
-gtk-win32-theme-part(window, 8, 1);
|
||||
background-size: 100% -gtk-win32-size(window, cycaption),
|
||||
100% calc(-gtk-win32-size(window, cyframe) + -gtk-win32-size(window, cxpaddedborder)),
|
||||
calc(-gtk-win32-size(window, cxframe) + -gtk-win32-size(window, cxpaddedborder)) calc(100% - 2 * (-gtk-win32-size(window, cyframe) + -gtk-win32-size(window, cxpaddedborder))),
|
||||
calc(-gtk-win32-size(window, cxframe) + -gtk-win32-size(window, cxpaddedborder)) calc(100% - 2 * (-gtk-win32-size(window, cyframe) + -gtk-win32-size(window, cxpaddedborder)));
|
||||
background-position: top, bottom, left, right;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
/* Unset above settings when the window is a popup menu or tooltip */
|
||||
* window decoration, tooltip decoration {
|
||||
all: unset;
|
||||
}
|
||||
|
||||
.titlebar {
|
||||
margin: calc(0px - -gtk-win32-size(window, cyframe) - -gtk-win32-size(window, cxpaddedborder))
|
||||
calc(0px - -gtk-win32-size(window, cxframe) - -gtk-win32-size(window, cxpaddedborder));
|
||||
margin-bottom: 0px;
|
||||
padding: calc(-gtk-win32-size(window, cyframe) + -gtk-win32-size(window, cxpaddedborder))
|
||||
calc(-gtk-win32-size(window, cxframe) + -gtk-win32-size(window, cxpaddedborder));
|
||||
padding-bottom: 0px;
|
||||
background: -gtk-win32-theme-part(window, 1, 1);
|
||||
min-height: calc(-gtk-win32-size(window, cycaption) - -gtk-win32-size(window, cyframe) - -gtk-win32-size(window, cxpaddedborder));
|
||||
}
|
||||
|
||||
decoration:backdrop {
|
||||
background-image: -gtk-win32-theme-part(window, 1, 2),
|
||||
-gtk-win32-theme-part(window, 9, 2),
|
||||
-gtk-win32-theme-part(window, 7, 2),
|
||||
-gtk-win32-theme-part(window, 8, 2);
|
||||
}
|
||||
.titlebar:backdrop {
|
||||
background: -gtk-win32-theme-part(window, 1, 2);
|
||||
}
|
||||
|
||||
decoration:disabled {
|
||||
background-image: -gtk-win32-theme-part(window, 1, 3),
|
||||
-gtk-win32-theme-part(window, 9, 3),
|
||||
-gtk-win32-theme-part(window, 7, 3),
|
||||
-gtk-win32-theme-part(window, 8, 3);
|
||||
}
|
||||
.titlebar:disabled {
|
||||
background: -gtk-win32-theme-part(window, 1, 3);
|
||||
}
|
||||
|
||||
.titlebar button.titlebutton {
|
||||
margin-top: -gtk-win32-size(button, cyedge);
|
||||
margin-bottom: -gtk-win32-size(button, cyedge);
|
||||
margin-right: -gtk-win32-size(button, cxedge);
|
||||
min-width: calc(-gtk-win32-size(button, cxsize) - 2 * -gtk-win32-size(button, cxedge));
|
||||
min-height: calc(-gtk-win32-size(button, cysize) - 2 * -gtk-win32-size(button, cyedge));
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100% calc(-gtk-win32-size(button, cysize) - 2 * -gtk-win32-size(button, cyedge));
|
||||
background-position: 50% calc(100% - -gtk-win32-size(window, cycaption) + -gtk-win32-size(window, cysize) - -gtk-win32-size(window, cyedge));
|
||||
}
|
||||
|
||||
/* XXX: headerbar insists on 6px spacing between buttons. Windows doesn't
|
||||
* think so. */
|
||||
.titlebar .titlebutton + .titlebutton {
|
||||
margin-left: -6px;
|
||||
}
|
||||
|
||||
/* XXX: We don't draw icons here, but the GtkImage still sizes itself to 16x16,
|
||||
* so shrink it enough: */
|
||||
.titlebar button.titlebutton image {
|
||||
margin: -3px;
|
||||
}
|
||||
|
||||
.titlebar button.close {
|
||||
background-image: -gtk-win32-theme-part(window, 18, 1);
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.titlebar button.close:hover {
|
||||
background-image: -gtk-win32-theme-part(window, 18, 2);
|
||||
}
|
||||
|
||||
.titlebar button.close:active {
|
||||
background-image: -gtk-win32-theme-part(window, 18, 3);
|
||||
}
|
||||
|
||||
.titlebar button.close:disabled {
|
||||
background-image: -gtk-win32-theme-part(window, 18, 4);
|
||||
}
|
||||
|
||||
.titlebar button.minimize {
|
||||
background-image: -gtk-win32-theme-part(window, 15, 1);
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.titlebar button.minimize:hover {
|
||||
background-image: -gtk-win32-theme-part(window, 15, 2);
|
||||
}
|
||||
|
||||
.titlebar button.minimize:active {
|
||||
background-image: -gtk-win32-theme-part(window, 15, 3);
|
||||
}
|
||||
|
||||
.titlebar button.minimize:disabled {
|
||||
background-image: -gtk-win32-theme-part(window, 15, 4);
|
||||
}
|
||||
|
||||
.titlebar button.maximize {
|
||||
background-image: -gtk-win32-theme-part(window, 17, 1);
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.titlebar button.maximize:hover {
|
||||
background-image: -gtk-win32-theme-part(window, 17, 2);
|
||||
}
|
||||
|
||||
.titlebar button.maximize:active {
|
||||
background-image: -gtk-win32-theme-part(window, 17, 3);
|
||||
}
|
||||
|
||||
.titlebar button.maximize:disabled {
|
||||
background-image: -gtk-win32-theme-part(window, 17, 4);
|
||||
}
|
||||
|
||||
.maximized .titlebar button.maximize {
|
||||
background-image: -gtk-win32-theme-part(window, 21, 1);
|
||||
}
|
||||
|
||||
.maximized .titlebar button.maximize:hover {
|
||||
background-image: -gtk-win32-theme-part(window, 21, 2);
|
||||
}
|
||||
|
||||
.maximized .titlebar button.maximize:active {
|
||||
background-image: -gtk-win32-theme-part(window, 21, 3);
|
||||
}
|
||||
|
||||
.maximized .titlebar button.maximize:disabled {
|
||||
background-image: -gtk-win32-theme-part(window, 21, 4);
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
a {
|
||||
background: -gtk-win32-color(edit, highlight);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
a {
|
||||
background-clip: border-box;
|
||||
background-color: -gtk-win32-color(edit, highlight);
|
||||
background-image: none;
|
||||
background-origin: padding-box;
|
||||
background-position: left top;
|
||||
background-repeat: repeat;
|
||||
background-size: auto;
|
||||
}
|
||||
@@ -157,8 +157,6 @@ test_data = [
|
||||
'background-shorthand-single.ref.css',
|
||||
'background-size.css',
|
||||
'background-size.ref.css',
|
||||
'background-win32-color-is-no-error.css',
|
||||
'background-win32-color-is-no-error.ref.css',
|
||||
'border-color.css',
|
||||
'border-color-currentcolor.css',
|
||||
'border-color-currentcolor.ref.css',
|
||||
|
||||
Reference in New Issue
Block a user