OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "views/controls/textfield/gtk_views_entry.h" | 5 #include "views/controls/textfield/gtk_views_entry.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "gfx/canvas_skia_paint.h" | 8 #include "gfx/canvas_skia_paint.h" |
9 #include "gfx/insets.h" | 9 #include "gfx/insets.h" |
10 #include "gfx/skia_utils_gtk.h" | 10 #include "gfx/skia_utils_gtk.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 if (host && event->window == entry->text_area && | 38 if (host && event->window == entry->text_area && |
39 !host->textfield()->text_to_display_when_empty().empty() && | 39 !host->textfield()->text_to_display_when_empty().empty() && |
40 g_utf8_strlen(gtk_entry_get_text(entry), -1) == 0) { | 40 g_utf8_strlen(gtk_entry_get_text(entry), -1) == 0) { |
41 gfx::CanvasSkiaPaint canvas(event); | 41 gfx::CanvasSkiaPaint canvas(event); |
42 if (!canvas.is_empty()) { | 42 if (!canvas.is_empty()) { |
43 gfx::Insets insets = | 43 gfx::Insets insets = |
44 views::NativeTextfieldGtk::GetEntryInnerBorder(entry); | 44 views::NativeTextfieldGtk::GetEntryInnerBorder(entry); |
45 gfx::Font font = host->textfield()->font(); | 45 gfx::Font font = host->textfield()->font(); |
46 const string16 text = host->textfield()->text_to_display_when_empty(); | 46 const string16 text = host->textfield()->text_to_display_when_empty(); |
47 canvas.DrawStringInt( | 47 canvas.DrawStringInt( |
48 UTF16ToWide(text), font, | 48 text, font, |
49 gfx::GdkColorToSkColor(widget->style->text[GTK_STATE_INSENSITIVE]), | 49 gfx::GdkColorToSkColor(widget->style->text[GTK_STATE_INSENSITIVE]), |
50 insets.left(), insets.top(), | 50 insets.left(), insets.top(), |
51 widget->allocation.width - insets.width(), font.GetHeight()); | 51 widget->allocation.width - insets.width(), font.GetHeight()); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 return result; | 55 return result; |
56 } | 56 } |
57 | 57 |
58 static void gtk_views_entry_class_init(GtkViewsEntryClass* views_entry_class) { | 58 static void gtk_views_entry_class_init(GtkViewsEntryClass* views_entry_class) { |
59 GtkWidgetClass* widget_class = | 59 GtkWidgetClass* widget_class = |
60 reinterpret_cast<GtkWidgetClass*>(views_entry_class); | 60 reinterpret_cast<GtkWidgetClass*>(views_entry_class); |
61 widget_class->expose_event = gtk_views_entry_expose_event; | 61 widget_class->expose_event = gtk_views_entry_expose_event; |
62 } | 62 } |
63 | 63 |
64 static void gtk_views_entry_init(GtkViewsEntry* entry) { | 64 static void gtk_views_entry_init(GtkViewsEntry* entry) { |
65 entry->host = NULL; | 65 entry->host = NULL; |
66 } | 66 } |
67 | 67 |
68 GtkWidget* gtk_views_entry_new(views::NativeTextfieldGtk* host) { | 68 GtkWidget* gtk_views_entry_new(views::NativeTextfieldGtk* host) { |
69 gpointer entry = g_object_new(GTK_TYPE_VIEWS_ENTRY, NULL); | 69 gpointer entry = g_object_new(GTK_TYPE_VIEWS_ENTRY, NULL); |
70 GTK_VIEWS_ENTRY(entry)->host = host; | 70 GTK_VIEWS_ENTRY(entry)->host = host; |
71 return GTK_WIDGET(entry); | 71 return GTK_WIDGET(entry); |
72 } | 72 } |
73 | 73 |
74 G_END_DECLS | 74 G_END_DECLS |
OLD | NEW |