[gtk+] win32 theme: Make entries and textview work



commit 3a9ceffe12927fd229e91623d476b53a70618d42
Author: Benjamin Otte <otte gnome org>
Date:   Tue Feb 23 05:05:37 2016 +0100

    win32 theme: Make entries and textview work

 gtk/gtkwin32draw.c                 |   41 ++++++++++++++++++++++++++++++
 gtk/theme/win32/gtk-win32-base.css |   48 +++++++++++++++++++++++------------
 2 files changed, 72 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtkwin32draw.c b/gtk/gtkwin32draw.c
index 0483723..84b50f2 100644
--- a/gtk/gtkwin32draw.c
+++ b/gtk/gtkwin32draw.c
@@ -187,6 +187,41 @@ draw_radio (cairo_t *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,
@@ -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 },
diff --git a/gtk/theme/win32/gtk-win32-base.css b/gtk/theme/win32/gtk-win32-base.css
index 1c5026f..41b343f 100644
--- a/gtk/theme/win32/gtk-win32-base.css
+++ b/gtk/theme/win32/gtk-win32-base.css
@@ -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;
+    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 {
+    background-image: -gtk-win32-theme-part(edit, 1, 3);
+}
+
+textview.view:disabled,
 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;
+    background-image: -gtk-win32-theme-part(edit, 1, 4);
+    color: -gtk-win32-color(edit, graytext);
 }
-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));
+
+selection {
+    background: -gtk-win32-color(edit, highlight);
+    color: -gtk-win32-color(edit, highlighttext);
 }
-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));
+
+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 */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]