OLD | NEW |
1 // Copyright (c) 2009 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 <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
6 | 6 |
7 #include "views/controls/textfield/native_textfield_gtk.h" | 7 #include "views/controls/textfield/native_textfield_gtk.h" |
8 | 8 |
9 #include "app/gfx/insets.h" | 9 #include "app/gfx/insets.h" |
10 #include "app/gfx/gtk_util.h" | 10 #include "app/gfx/gtk_util.h" |
| 11 #include "app/gfx/skia_utils_gtk.h" |
11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
12 #include "skia/ext/skia_utils_gtk.h" | |
13 #include "views/controls/textfield/textfield.h" | 13 #include "views/controls/textfield/textfield.h" |
14 | 14 |
15 namespace views { | 15 namespace views { |
16 // A character used to hide a text in password mode. | 16 // A character used to hide a text in password mode. |
17 const char kPasswordChar = '*'; | 17 const char kPasswordChar = '*'; |
18 | 18 |
19 //////////////////////////////////////////////////////////////////////////////// | 19 //////////////////////////////////////////////////////////////////////////////// |
20 // NativeTextfieldGtk, public: | 20 // NativeTextfieldGtk, public: |
21 | 21 |
22 NativeTextfieldGtk::NativeTextfieldGtk(Textfield* textfield) | 22 NativeTextfieldGtk::NativeTextfieldGtk(Textfield* textfield) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 gtk_entry_set_has_frame(GTK_ENTRY(native_view()), false); | 90 gtk_entry_set_has_frame(GTK_ENTRY(native_view()), false); |
91 } | 91 } |
92 | 92 |
93 void NativeTextfieldGtk::UpdateTextColor() { | 93 void NativeTextfieldGtk::UpdateTextColor() { |
94 if (textfield_->use_default_text_color()) { | 94 if (textfield_->use_default_text_color()) { |
95 // Passing NULL as the color undoes the effect of previous calls to | 95 // Passing NULL as the color undoes the effect of previous calls to |
96 // gtk_widget_modify_text. | 96 // gtk_widget_modify_text. |
97 gtk_widget_modify_text(native_view(), GTK_STATE_NORMAL, NULL); | 97 gtk_widget_modify_text(native_view(), GTK_STATE_NORMAL, NULL); |
98 return; | 98 return; |
99 } | 99 } |
100 GdkColor gdk_color = skia::SkColorToGdkColor(textfield_->text_color()); | 100 GdkColor gdk_color = gfx::SkColorToGdkColor(textfield_->text_color()); |
101 gtk_widget_modify_text(native_view(), GTK_STATE_NORMAL, &gdk_color); | 101 gtk_widget_modify_text(native_view(), GTK_STATE_NORMAL, &gdk_color); |
102 } | 102 } |
103 | 103 |
104 void NativeTextfieldGtk::UpdateBackgroundColor() { | 104 void NativeTextfieldGtk::UpdateBackgroundColor() { |
105 if (textfield_->use_default_background_color()) { | 105 if (textfield_->use_default_background_color()) { |
106 // Passing NULL as the color undoes the effect of previous calls to | 106 // Passing NULL as the color undoes the effect of previous calls to |
107 // gtk_widget_modify_base. | 107 // gtk_widget_modify_base. |
108 gtk_widget_modify_base(native_view(), GTK_STATE_NORMAL, NULL); | 108 gtk_widget_modify_base(native_view(), GTK_STATE_NORMAL, NULL); |
109 return; | 109 return; |
110 } | 110 } |
111 GdkColor gdk_color = skia::SkColorToGdkColor(textfield_->background_color()); | 111 GdkColor gdk_color = gfx::SkColorToGdkColor(textfield_->background_color()); |
112 gtk_widget_modify_base(native_view(), GTK_STATE_NORMAL, &gdk_color); | 112 gtk_widget_modify_base(native_view(), GTK_STATE_NORMAL, &gdk_color); |
113 } | 113 } |
114 | 114 |
115 void NativeTextfieldGtk::UpdateReadOnly() { | 115 void NativeTextfieldGtk::UpdateReadOnly() { |
116 if (!native_view()) | 116 if (!native_view()) |
117 return; | 117 return; |
118 gtk_editable_set_editable(GTK_EDITABLE(native_view()), | 118 gtk_editable_set_editable(GTK_EDITABLE(native_view()), |
119 !textfield_->read_only()); | 119 !textfield_->read_only()); |
120 } | 120 } |
121 | 121 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 //////////////////////////////////////////////////////////////////////////////// | 251 //////////////////////////////////////////////////////////////////////////////// |
252 // NativeTextfieldWrapper, public: | 252 // NativeTextfieldWrapper, public: |
253 | 253 |
254 // static | 254 // static |
255 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | 255 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
256 Textfield* field) { | 256 Textfield* field) { |
257 return new NativeTextfieldGtk(field); | 257 return new NativeTextfieldGtk(field); |
258 } | 258 } |
259 | 259 |
260 } // namespace views | 260 } // namespace views |
OLD | NEW |