win32 theme: Make entries and textview work

This commit is contained in:
Benjamin Otte 2016-02-23 05:05:37 +01:00
parent 4e8fb33f56
commit 3a9ceffe12
2 changed files with 74 additions and 19 deletions

View File

@ -186,6 +186,41 @@ draw_radio (cairo_t *cr,
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,
@ -270,6 +305,12 @@ 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 },
{ "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 },
{ "tooltip", 1, 0, { 0, 0, 0, 0 }, draw_tooltip },
{ "window", 1, 0, { 0, 0, 0, 0 }, draw_window },
{ "window", 15, 0, { 0, 0, 0, 0 }, draw_window_button },

View File

@ -467,28 +467,42 @@ scrollbar.vertical slider:disabled {
/* Entry */
/* We apply the border as a border combined with the background so that
gtk_entry_set_has_frame works */
textview.view,
entry {
border-width: 1px;
border-style: solid;
border-image: -gtk-win32-theme-part(edit, 6, 1) 1 1 1 1 stretch;
background-image: -gtk-win32-theme-part(edit, 6, 1, margins(-1 -1 -1 -1));
padding: 2px;
}
entry:disabled {
border-image: -gtk-win32-theme-part(edit, 6, 4) 1 1 1 1 stretch;
background-image: -gtk-win32-theme-part(edit, 6, 4, margins(-1 -1 -1 -1));
color: #a7aba7;
}
entry:hover {
border-image: -gtk-win32-theme-part(edit, 6, 2) 1 1 1 1 stretch;
background-image: -gtk-win32-theme-part(edit, 6, 2, margins(-1 -1 -1 -1));
background-image: -gtk-win32-theme-part(edit, 1, 1);
/* The 1em/3 is the "margin" that Windows uses. I'm pretty sure that's the "ABC width"
of the font. But we don't get those fancy things in CSS. */
padding: -gtk-win32-size(edit, cyedge) calc(-gtk-win32-size(edit, cxedge) + 1em/3);
}
textview.view:focus,
entry:focus {
border-image: -gtk-win32-theme-part(edit, 6, 3) 1 1 1 1 stretch;
background-image: -gtk-win32-theme-part(edit, 6, 3, margins(-1 -1 -1 -1));
background-image: -gtk-win32-theme-part(edit, 1, 3);
}
textview.view:disabled,
entry:disabled {
background-image: -gtk-win32-theme-part(edit, 1, 4);
color: -gtk-win32-color(edit, graytext);
}
selection {
background: -gtk-win32-color(edit, highlight);
color: -gtk-win32-color(edit, highlighttext);
}
entry.flat {
padding: 0px;
background-image: -gtk-win32-theme-part(edit, 3, 1);
}
entry.flat:focus {
background-image: -gtk-win32-theme-part(edit, 3, 3);
}
entry.flat:disabled {
background-image: -gtk-win32-theme-part(edit, 3, 4);
color: -gtk-win32-color(edit, graytext);
}
/* Spibuttons */