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/textfield.h" | 5 #include "views/controls/textfield/textfield.h" |
6 | 6 |
7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "app/keyboard_codes.h" | 13 #include "base/keyboard_codes.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "gfx/insets.h" | 16 #include "gfx/insets.h" |
17 #include "views/controls/native/native_view_host.h" | 17 #include "views/controls/native/native_view_host.h" |
18 #include "views/controls/textfield/native_textfield_wrapper.h" | 18 #include "views/controls/textfield/native_textfield_wrapper.h" |
19 #include "views/widget/widget.h" | 19 #include "views/widget/widget.h" |
20 | 20 |
21 #if defined(OS_LINUX) | 21 #if defined(OS_LINUX) |
22 #include "app/keyboard_code_conversion_gtk.h" | 22 #include "base/keyboard_code_conversion_gtk.h" |
23 #elif defined(OS_WIN) | 23 #elif defined(OS_WIN) |
24 #include "app/win_util.h" | 24 #include "app/win_util.h" |
25 #include "base/win_util.h" | 25 #include "base/win_util.h" |
26 // TODO(beng): this should be removed when the OS_WIN hack from | 26 // TODO(beng): this should be removed when the OS_WIN hack from |
27 // ViewHierarchyChanged is removed. | 27 // ViewHierarchyChanged is removed. |
28 #include "views/controls/textfield/native_textfield_win.h" | 28 #include "views/controls/textfield/native_textfield_win.h" |
29 #endif | 29 #endif |
30 | 30 |
31 namespace views { | 31 namespace views { |
32 | 32 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 return IsEnabled() && !read_only_; | 232 return IsEnabled() && !read_only_; |
233 } | 233 } |
234 | 234 |
235 void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) { | 235 void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) { |
236 SelectAll(); | 236 SelectAll(); |
237 } | 237 } |
238 | 238 |
239 bool Textfield::SkipDefaultKeyEventProcessing(const KeyEvent& e) { | 239 bool Textfield::SkipDefaultKeyEventProcessing(const KeyEvent& e) { |
240 // TODO(hamaji): Figure out which keyboard combinations we need to add here, | 240 // TODO(hamaji): Figure out which keyboard combinations we need to add here, |
241 // similar to LocationBarView::SkipDefaultKeyEventProcessing. | 241 // similar to LocationBarView::SkipDefaultKeyEventProcessing. |
242 app::KeyboardCode key = e.GetKeyCode(); | 242 base::KeyboardCode key = e.GetKeyCode(); |
243 if (key == app::VKEY_BACK) | 243 if (key == base::VKEY_BACK) |
244 return true; // We'll handle BackSpace ourselves. | 244 return true; // We'll handle BackSpace ourselves. |
245 | 245 |
246 #if defined(OS_WIN) | 246 #if defined(OS_WIN) |
247 // We don't translate accelerators for ALT + NumPad digit on Windows, they are | 247 // We don't translate accelerators for ALT + NumPad digit on Windows, they are |
248 // used for entering special characters. We do translate alt-home. | 248 // used for entering special characters. We do translate alt-home. |
249 if (e.IsAltDown() && (key != app::VKEY_HOME) && | 249 if (e.IsAltDown() && (key != base::VKEY_HOME) && |
250 win_util::IsNumPadDigit(key, e.IsExtendedKey())) | 250 win_util::IsNumPadDigit(key, e.IsExtendedKey())) |
251 return true; | 251 return true; |
252 #endif | 252 #endif |
253 return false; | 253 return false; |
254 } | 254 } |
255 | 255 |
256 void Textfield::PaintFocusBorder(gfx::Canvas* canvas) { | 256 void Textfield::PaintFocusBorder(gfx::Canvas* canvas) { |
257 if (NativeViewHost::kRenderNativeControlFocus) | 257 if (NativeViewHost::kRenderNativeControlFocus) |
258 View::PaintFocusBorder(canvas); | 258 View::PaintFocusBorder(canvas); |
259 } | 259 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 // Remove the include for native_textfield_win.h above when you fix this. | 325 // Remove the include for native_textfield_win.h above when you fix this. |
326 static_cast<NativeTextfieldWin*>(native_wrapper_)->AttachHack(); | 326 static_cast<NativeTextfieldWin*>(native_wrapper_)->AttachHack(); |
327 #endif | 327 #endif |
328 } | 328 } |
329 } | 329 } |
330 | 330 |
331 std::string Textfield::GetClassName() const { | 331 std::string Textfield::GetClassName() const { |
332 return kViewClassName; | 332 return kViewClassName; |
333 } | 333 } |
334 | 334 |
335 app::KeyboardCode Textfield::Keystroke::GetKeyboardCode() const { | 335 base::KeyboardCode Textfield::Keystroke::GetKeyboardCode() const { |
336 #if defined(OS_WIN) | 336 #if defined(OS_WIN) |
337 return static_cast<app::KeyboardCode>(key_); | 337 return static_cast<base::KeyboardCode>(key_); |
338 #else | 338 #else |
339 return static_cast<app::KeyboardCode>( | 339 return static_cast<base::KeyboardCode>( |
340 app::WindowsKeyCodeForGdkKeyCode(event_.keyval)); | 340 base::WindowsKeyCodeForGdkKeyCode(event_.keyval)); |
341 #endif | 341 #endif |
342 } | 342 } |
343 | 343 |
344 #if defined(OS_WIN) | 344 #if defined(OS_WIN) |
345 bool Textfield::Keystroke::IsControlHeld() const { | 345 bool Textfield::Keystroke::IsControlHeld() const { |
346 return win_util::IsCtrlPressed(); | 346 return win_util::IsCtrlPressed(); |
347 } | 347 } |
348 | 348 |
349 bool Textfield::Keystroke::IsShiftHeld() const { | 349 bool Textfield::Keystroke::IsShiftHeld() const { |
350 return win_util::IsShiftPressed(); | 350 return win_util::IsShiftPressed(); |
351 } | 351 } |
352 #else | 352 #else |
353 bool Textfield::Keystroke::IsControlHeld() const { | 353 bool Textfield::Keystroke::IsControlHeld() const { |
354 return (event_.state & gtk_accelerator_get_default_mod_mask()) == | 354 return (event_.state & gtk_accelerator_get_default_mod_mask()) == |
355 GDK_CONTROL_MASK; | 355 GDK_CONTROL_MASK; |
356 } | 356 } |
357 | 357 |
358 bool Textfield::Keystroke::IsShiftHeld() const { | 358 bool Textfield::Keystroke::IsShiftHeld() const { |
359 return (event_.state & gtk_accelerator_get_default_mod_mask()) == | 359 return (event_.state & gtk_accelerator_get_default_mod_mask()) == |
360 GDK_SHIFT_MASK; | 360 GDK_SHIFT_MASK; |
361 } | 361 } |
362 #endif | 362 #endif |
363 | 363 |
364 } // namespace views | 364 } // namespace views |
OLD | NEW |