OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/views/controls/textfield/native_textfield_win.h" | 5 #include "ui/views/controls/textfield/native_textfield_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 // Setting the font blows away any text color we've set, so reset it. | 259 // Setting the font blows away any text color we've set, so reset it. |
260 UpdateTextColor(); | 260 UpdateTextColor(); |
261 } | 261 } |
262 | 262 |
263 void NativeTextfieldWin::UpdateIsPassword() { | 263 void NativeTextfieldWin::UpdateIsPassword() { |
264 // TODO: Need to implement for Windows. | 264 // TODO: Need to implement for Windows. |
265 UpdateAccessibleState(STATE_SYSTEM_PROTECTED, textfield_->IsPassword()); | 265 UpdateAccessibleState(STATE_SYSTEM_PROTECTED, textfield_->IsPassword()); |
266 } | 266 } |
267 | 267 |
268 void NativeTextfieldWin::UpdateEnabled() { | 268 void NativeTextfieldWin::UpdateEnabled() { |
269 SendMessage(m_hWnd, WM_ENABLE, textfield_->IsEnabled(), 0); | 269 SendMessage(m_hWnd, WM_ENABLE, textfield_->enabled(), 0); |
270 UpdateAccessibleState(STATE_SYSTEM_UNAVAILABLE, !textfield_->IsEnabled()); | 270 UpdateAccessibleState(STATE_SYSTEM_UNAVAILABLE, !textfield_->enabled()); |
271 } | 271 } |
272 | 272 |
273 gfx::Insets NativeTextfieldWin::CalculateInsets() { | 273 gfx::Insets NativeTextfieldWin::CalculateInsets() { |
274 // NOTE: One would think GetThemeMargins would return the insets we should | 274 // NOTE: One would think GetThemeMargins would return the insets we should |
275 // use, but it doesn't. The margins returned by GetThemeMargins are always | 275 // use, but it doesn't. The margins returned by GetThemeMargins are always |
276 // 0. | 276 // 0. |
277 | 277 |
278 // This appears to be the insets used by Windows. | 278 // This appears to be the insets used by Windows. |
279 return gfx::Insets(3, 3, 3, 3); | 279 return gfx::Insets(3, 3, 3, 3); |
280 } | 280 } |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 HBRUSH brush = CreateSolidBrush(bg_color_); | 853 HBRUSH brush = CreateSolidBrush(bg_color_); |
854 FillRect(hdc, &window_rect, brush); | 854 FillRect(hdc, &window_rect, brush); |
855 DeleteObject(brush); | 855 DeleteObject(brush); |
856 | 856 |
857 int part; | 857 int part; |
858 int state; | 858 int state; |
859 | 859 |
860 if (base::win::GetVersion() < base::win::VERSION_VISTA) { | 860 if (base::win::GetVersion() < base::win::VERSION_VISTA) { |
861 part = EP_EDITTEXT; | 861 part = EP_EDITTEXT; |
862 | 862 |
863 if (!textfield_->IsEnabled()) | 863 if (!textfield_->enabled()) |
864 state = ETS_DISABLED; | 864 state = ETS_DISABLED; |
865 else if (textfield_->read_only()) | 865 else if (textfield_->read_only()) |
866 state = ETS_READONLY; | 866 state = ETS_READONLY; |
867 else if (!contains_mouse_) | 867 else if (!contains_mouse_) |
868 state = ETS_NORMAL; | 868 state = ETS_NORMAL; |
869 else | 869 else |
870 state = ETS_HOT; | 870 state = ETS_HOT; |
871 } else { | 871 } else { |
872 part = EP_EDITBORDER_HVSCROLL; | 872 part = EP_EDITBORDER_HVSCROLL; |
873 | 873 |
874 if (!textfield_->IsEnabled()) | 874 if (!textfield_->enabled()) |
875 state = EPSHV_DISABLED; | 875 state = EPSHV_DISABLED; |
876 else if (GetFocus() == m_hWnd) | 876 else if (GetFocus() == m_hWnd) |
877 state = EPSHV_FOCUSED; | 877 state = EPSHV_FOCUSED; |
878 else if (contains_mouse_) | 878 else if (contains_mouse_) |
879 state = EPSHV_HOT; | 879 state = EPSHV_HOT; |
880 else | 880 else |
881 state = EPSHV_NORMAL; | 881 state = EPSHV_NORMAL; |
882 // Vista doesn't appear to have a unique state for readonly. | 882 // Vista doesn't appear to have a unique state for readonly. |
883 } | 883 } |
884 | 884 |
885 int classic_state = | 885 int classic_state = |
886 (!textfield_->IsEnabled() || textfield_->read_only()) ? DFCS_INACTIVE : 0; | 886 (!textfield_->enabled() || textfield_->read_only()) ? DFCS_INACTIVE : 0; |
887 | 887 |
888 gfx::NativeThemeWin::instance()->PaintTextField(hdc, part, state, | 888 gfx::NativeThemeWin::instance()->PaintTextField(hdc, part, state, |
889 classic_state, &window_rect, | 889 classic_state, &window_rect, |
890 bg_color_, false, true); | 890 bg_color_, false, true); |
891 | 891 |
892 // NOTE: I tried checking the transparent property of the theme and invoking | 892 // NOTE: I tried checking the transparent property of the theme and invoking |
893 // drawParentBackground, but it didn't seem to make a difference. | 893 // drawParentBackground, but it didn't seem to make a difference. |
894 | 894 |
895 ReleaseDC(hdc); | 895 ReleaseDC(hdc); |
896 } | 896 } |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 | 1153 |
1154 // static | 1154 // static |
1155 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | 1155 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
1156 Textfield* field) { | 1156 Textfield* field) { |
1157 if (views::Widget::IsPureViews()) | 1157 if (views::Widget::IsPureViews()) |
1158 return new NativeTextfieldViews(field); | 1158 return new NativeTextfieldViews(field); |
1159 return new NativeTextfieldWin(field); | 1159 return new NativeTextfieldWin(field); |
1160 } | 1160 } |
1161 | 1161 |
1162 } // namespace views | 1162 } // namespace views |
OLD | NEW |