| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/views/text_field.h" | 5 #include "chrome/views/text_field.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlapp.h> | 8 #include <atlapp.h> |
| 9 #include <atlcrack.h> | 9 #include <atlcrack.h> |
| 10 #include <atlctrls.h> | 10 #include <atlctrls.h> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 void SetEnabled(bool enabled); | 64 void SetEnabled(bool enabled); |
| 65 | 65 |
| 66 void SetBackgroundColor(COLORREF bg_color); | 66 void SetBackgroundColor(COLORREF bg_color); |
| 67 | 67 |
| 68 // CWindowImpl | 68 // CWindowImpl |
| 69 BEGIN_MSG_MAP(Edit) | 69 BEGIN_MSG_MAP(Edit) |
| 70 MSG_WM_CHAR(OnChar) | 70 MSG_WM_CHAR(OnChar) |
| 71 MSG_WM_CONTEXTMENU(OnContextMenu) | 71 MSG_WM_CONTEXTMENU(OnContextMenu) |
| 72 MSG_WM_COPY(OnCopy) | 72 MSG_WM_COPY(OnCopy) |
| 73 MSG_WM_CREATE(OnCreate) | |
| 74 MSG_WM_CUT(OnCut) | 73 MSG_WM_CUT(OnCut) |
| 75 MSG_WM_DESTROY(OnDestroy) | |
| 76 MESSAGE_HANDLER_EX(WM_IME_STARTCOMPOSITION, OnImeStartComposition) | 74 MESSAGE_HANDLER_EX(WM_IME_STARTCOMPOSITION, OnImeStartComposition) |
| 77 MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeComposition) | 75 MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeComposition) |
| 78 MSG_WM_KEYDOWN(OnKeyDown) | 76 MSG_WM_KEYDOWN(OnKeyDown) |
| 79 MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk) | 77 MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk) |
| 80 MSG_WM_LBUTTONDOWN(OnLButtonDown) | 78 MSG_WM_LBUTTONDOWN(OnLButtonDown) |
| 81 MSG_WM_LBUTTONUP(OnLButtonUp) | 79 MSG_WM_LBUTTONUP(OnLButtonUp) |
| 82 MSG_WM_MBUTTONDOWN(OnNonLButtonDown) | 80 MSG_WM_MBUTTONDOWN(OnNonLButtonDown) |
| 83 MSG_WM_MOUSEMOVE(OnMouseMove) | 81 MSG_WM_MOUSEMOVE(OnMouseMove) |
| 84 MSG_WM_MOUSELEAVE(OnMouseLeave) | 82 MSG_WM_MOUSELEAVE(OnMouseLeave) |
| 85 MSG_WM_NCCALCSIZE(OnNCCalcSize) | 83 MSG_WM_NCCALCSIZE(OnNCCalcSize) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 111 Edit* const edit_; | 109 Edit* const edit_; |
| 112 ITextDocument* const text_object_model_; | 110 ITextDocument* const text_object_model_; |
| 113 | 111 |
| 114 DISALLOW_EVIL_CONSTRUCTORS(ScopedFreeze); | 112 DISALLOW_EVIL_CONSTRUCTORS(ScopedFreeze); |
| 115 }; | 113 }; |
| 116 | 114 |
| 117 // message handlers | 115 // message handlers |
| 118 void OnChar(TCHAR key, UINT repeat_count, UINT flags); | 116 void OnChar(TCHAR key, UINT repeat_count, UINT flags); |
| 119 void OnContextMenu(HWND window, const CPoint& point); | 117 void OnContextMenu(HWND window, const CPoint& point); |
| 120 void OnCopy(); | 118 void OnCopy(); |
| 121 LRESULT OnCreate(CREATESTRUCT* create_struct); | |
| 122 void OnCut(); | 119 void OnCut(); |
| 123 void OnDestroy(); | |
| 124 LRESULT OnImeStartComposition(UINT message, WPARAM wparam, LPARAM lparam); | 120 LRESULT OnImeStartComposition(UINT message, WPARAM wparam, LPARAM lparam); |
| 125 LRESULT OnImeComposition(UINT message, WPARAM wparam, LPARAM lparam); | 121 LRESULT OnImeComposition(UINT message, WPARAM wparam, LPARAM lparam); |
| 126 void OnKeyDown(TCHAR key, UINT repeat_count, UINT flags); | 122 void OnKeyDown(TCHAR key, UINT repeat_count, UINT flags); |
| 127 void OnLButtonDblClk(UINT keys, const CPoint& point); | 123 void OnLButtonDblClk(UINT keys, const CPoint& point); |
| 128 void OnLButtonDown(UINT keys, const CPoint& point); | 124 void OnLButtonDown(UINT keys, const CPoint& point); |
| 129 void OnLButtonUp(UINT keys, const CPoint& point); | 125 void OnLButtonUp(UINT keys, const CPoint& point); |
| 130 void OnMouseLeave(); | 126 void OnMouseLeave(); |
| 131 void OnMouseMove(UINT keys, const CPoint& point); | 127 void OnMouseMove(UINT keys, const CPoint& point); |
| 132 int OnNCCalcSize(BOOL w_param, LPARAM l_param); | 128 int OnNCCalcSize(BOOL w_param, LPARAM l_param); |
| 133 void OnNCPaint(HRGN region); | 129 void OnNCPaint(HRGN region); |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 | 407 |
| 412 void TextField::Edit::OnCopy() { | 408 void TextField::Edit::OnCopy() { |
| 413 const std::wstring text(GetSelectedText()); | 409 const std::wstring text(GetSelectedText()); |
| 414 | 410 |
| 415 if (!text.empty()) { | 411 if (!text.empty()) { |
| 416 ScopedClipboardWriter scw(g_browser_process->clipboard_service()); | 412 ScopedClipboardWriter scw(g_browser_process->clipboard_service()); |
| 417 scw.WriteText(text); | 413 scw.WriteText(text); |
| 418 } | 414 } |
| 419 } | 415 } |
| 420 | 416 |
| 421 LRESULT TextField::Edit::OnCreate(CREATESTRUCT* create_struct) { | |
| 422 TRACK_HWND_CREATION(m_hWnd); | |
| 423 return 0; | |
| 424 } | |
| 425 | |
| 426 void TextField::Edit::OnCut() { | 417 void TextField::Edit::OnCut() { |
| 427 if (parent_->IsReadOnly()) | 418 if (parent_->IsReadOnly()) |
| 428 return; | 419 return; |
| 429 | 420 |
| 430 OnCopy(); | 421 OnCopy(); |
| 431 | 422 |
| 432 // This replace selection will have no effect (even on the undo stack) if the | 423 // This replace selection will have no effect (even on the undo stack) if the |
| 433 // current selection is empty. | 424 // current selection is empty. |
| 434 ReplaceSel(L"", true); | 425 ReplaceSel(L"", true); |
| 435 } | 426 } |
| 436 | 427 |
| 437 void TextField::Edit::OnDestroy() { | |
| 438 TRACK_HWND_DESTRUCTION(m_hWnd); | |
| 439 } | |
| 440 | |
| 441 LRESULT TextField::Edit::OnImeStartComposition(UINT message, | 428 LRESULT TextField::Edit::OnImeStartComposition(UINT message, |
| 442 WPARAM wparam, | 429 WPARAM wparam, |
| 443 LPARAM lparam) { | 430 LPARAM lparam) { |
| 444 // Users may press alt+shift or control+shift keys to change their keyboard | 431 // Users may press alt+shift or control+shift keys to change their keyboard |
| 445 // layouts. So, we retrieve the input locale identifier everytime we start | 432 // layouts. So, we retrieve the input locale identifier everytime we start |
| 446 // an IME composition. | 433 // an IME composition. |
| 447 int language_id = PRIMARYLANGID(GetKeyboardLayout(0)); | 434 int language_id = PRIMARYLANGID(GetKeyboardLayout(0)); |
| 448 ime_discard_composition_ = | 435 ime_discard_composition_ = |
| 449 language_id == LANG_JAPANESE || language_id == LANG_CHINESE; | 436 language_id == LANG_JAPANESE || language_id == LANG_CHINESE; |
| 450 ime_composition_start_ = 0; | 437 ime_composition_start_ = 0; |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 | 1101 |
| 1115 COLORREF bg_color; | 1102 COLORREF bg_color; |
| 1116 if (!use_default_background_color_) | 1103 if (!use_default_background_color_) |
| 1117 bg_color = skia::SkColorToCOLORREF(background_color_); | 1104 bg_color = skia::SkColorToCOLORREF(background_color_); |
| 1118 else | 1105 else |
| 1119 bg_color = GetSysColor(read_only_ ? COLOR_3DFACE : COLOR_WINDOW); | 1106 bg_color = GetSysColor(read_only_ ? COLOR_3DFACE : COLOR_WINDOW); |
| 1120 edit_->SetBackgroundColor(bg_color); | 1107 edit_->SetBackgroundColor(bg_color); |
| 1121 } | 1108 } |
| 1122 | 1109 |
| 1123 } // namespace views | 1110 } // namespace views |
| OLD | NEW |