Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: chrome/views/controls/text_field.cc

Issue 73087: Make TextFields reroute mouse wheel messages (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/views/view_unittest.cc » ('j') | chrome/views/view_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/controls/text_field.h" 5 #include "chrome/views/controls/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>
11 #include <tom.h> // For ITextDocument, a COM interface to CRichEditCtrl 11 #include <tom.h> // For ITextDocument, a COM interface to CRichEditCtrl
12 #include <vsstyle.h> 12 #include <vsstyle.h>
13 13
14 #include "base/gfx/native_theme.h" 14 #include "base/gfx/native_theme.h"
15 #include "base/scoped_clipboard_writer.h" 15 #include "base/scoped_clipboard_writer.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "base/win_util.h" 17 #include "base/win_util.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/common/clipboard_service.h" 19 #include "chrome/common/clipboard_service.h"
20 #include "chrome/common/gfx/insets.h" 20 #include "chrome/common/gfx/insets.h"
21 #include "chrome/common/l10n_util.h" 21 #include "chrome/common/l10n_util.h"
22 #include "chrome/common/l10n_util_win.h" 22 #include "chrome/common/l10n_util_win.h"
23 #include "chrome/common/logging_chrome.h" 23 #include "chrome/common/logging_chrome.h"
24 #include "chrome/common/win_util.h" 24 #include "chrome/common/win_util.h"
25 #include "chrome/views/controls/hwnd_view.h" 25 #include "chrome/views/controls/hwnd_view.h"
26 #include "chrome/views/controls/menu/menu.h" 26 #include "chrome/views/controls/menu/menu.h"
27 #include "chrome/views/focus/focus_util_win.h"
27 #include "chrome/views/widget/widget.h" 28 #include "chrome/views/widget/widget.h"
28 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
29 #include "skia/ext/skia_utils_win.h" 30 #include "skia/ext/skia_utils_win.h"
30 31
31 using gfx::NativeTheme; 32 using gfx::NativeTheme;
32 33
33 namespace views { 34 namespace views {
34 35
35 static const int kDefaultEditStyle = WS_CHILD | WS_VISIBLE; 36 static const int kDefaultEditStyle = WS_CHILD | WS_VISIBLE;
36 37
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 MESSAGE_HANDLER_EX(WM_IME_CHAR, OnImeChar) 77 MESSAGE_HANDLER_EX(WM_IME_CHAR, OnImeChar)
77 MESSAGE_HANDLER_EX(WM_IME_STARTCOMPOSITION, OnImeStartComposition) 78 MESSAGE_HANDLER_EX(WM_IME_STARTCOMPOSITION, OnImeStartComposition)
78 MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeComposition) 79 MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeComposition)
79 MSG_WM_KEYDOWN(OnKeyDown) 80 MSG_WM_KEYDOWN(OnKeyDown)
80 MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk) 81 MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk)
81 MSG_WM_LBUTTONDOWN(OnLButtonDown) 82 MSG_WM_LBUTTONDOWN(OnLButtonDown)
82 MSG_WM_LBUTTONUP(OnLButtonUp) 83 MSG_WM_LBUTTONUP(OnLButtonUp)
83 MSG_WM_MBUTTONDOWN(OnNonLButtonDown) 84 MSG_WM_MBUTTONDOWN(OnNonLButtonDown)
84 MSG_WM_MOUSEMOVE(OnMouseMove) 85 MSG_WM_MOUSEMOVE(OnMouseMove)
85 MSG_WM_MOUSELEAVE(OnMouseLeave) 86 MSG_WM_MOUSELEAVE(OnMouseLeave)
87 MESSAGE_HANDLER_EX(WM_MOUSEWHEEL, OnMouseWheel)
86 MSG_WM_NCCALCSIZE(OnNCCalcSize) 88 MSG_WM_NCCALCSIZE(OnNCCalcSize)
87 MSG_WM_NCPAINT(OnNCPaint) 89 MSG_WM_NCPAINT(OnNCPaint)
88 MSG_WM_RBUTTONDOWN(OnNonLButtonDown) 90 MSG_WM_RBUTTONDOWN(OnNonLButtonDown)
89 MSG_WM_PASTE(OnPaste) 91 MSG_WM_PASTE(OnPaste)
90 MSG_WM_SYSCHAR(OnSysChar) // WM_SYSxxx == WM_xxx with ALT down 92 MSG_WM_SYSCHAR(OnSysChar) // WM_SYSxxx == WM_xxx with ALT down
91 MSG_WM_SYSKEYDOWN(OnKeyDown) 93 MSG_WM_SYSKEYDOWN(OnKeyDown)
92 END_MSG_MAP() 94 END_MSG_MAP()
93 95
94 // Menu::Delegate 96 // Menu::Delegate
95 virtual bool IsCommandEnabled(int id) const; 97 virtual bool IsCommandEnabled(int id) const;
(...skipping 27 matching lines...) Expand all
123 void OnCut(); 125 void OnCut();
124 void OnDestroy(); 126 void OnDestroy();
125 LRESULT OnImeChar(UINT message, WPARAM wparam, LPARAM lparam); 127 LRESULT OnImeChar(UINT message, WPARAM wparam, LPARAM lparam);
126 LRESULT OnImeStartComposition(UINT message, WPARAM wparam, LPARAM lparam); 128 LRESULT OnImeStartComposition(UINT message, WPARAM wparam, LPARAM lparam);
127 LRESULT OnImeComposition(UINT message, WPARAM wparam, LPARAM lparam); 129 LRESULT OnImeComposition(UINT message, WPARAM wparam, LPARAM lparam);
128 void OnKeyDown(TCHAR key, UINT repeat_count, UINT flags); 130 void OnKeyDown(TCHAR key, UINT repeat_count, UINT flags);
129 void OnLButtonDblClk(UINT keys, const CPoint& point); 131 void OnLButtonDblClk(UINT keys, const CPoint& point);
130 void OnLButtonDown(UINT keys, const CPoint& point); 132 void OnLButtonDown(UINT keys, const CPoint& point);
131 void OnLButtonUp(UINT keys, const CPoint& point); 133 void OnLButtonUp(UINT keys, const CPoint& point);
132 void OnMouseLeave(); 134 void OnMouseLeave();
135 LRESULT OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param);
133 void OnMouseMove(UINT keys, const CPoint& point); 136 void OnMouseMove(UINT keys, const CPoint& point);
134 int OnNCCalcSize(BOOL w_param, LPARAM l_param); 137 int OnNCCalcSize(BOOL w_param, LPARAM l_param);
135 void OnNCPaint(HRGN region); 138 void OnNCPaint(HRGN region);
136 void OnNonLButtonDown(UINT keys, const CPoint& point); 139 void OnNonLButtonDown(UINT keys, const CPoint& point);
137 void OnPaste(); 140 void OnPaste();
138 void OnSysChar(TCHAR ch, UINT repeat_count, UINT flags); 141 void OnSysChar(TCHAR ch, UINT repeat_count, UINT flags);
139 142
140 // Helper function for OnChar() and OnKeyDown() that handles keystrokes that 143 // Helper function for OnChar() and OnKeyDown() that handles keystrokes that
141 // could change the text in the edit. 144 // could change the text in the edit.
142 void HandleKeystroke(UINT message, TCHAR key, UINT repeat_count, UINT flags); 145 void HandleKeystroke(UINT message, TCHAR key, UINT repeat_count, UINT flags);
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 OnBeforePossibleChange(); 622 OnBeforePossibleChange();
620 DefWindowProc(WM_LBUTTONUP, keys, 623 DefWindowProc(WM_LBUTTONUP, keys,
621 MAKELPARAM(ClipXCoordToVisibleText(point.x, false), point.y)); 624 MAKELPARAM(ClipXCoordToVisibleText(point.x, false), point.y));
622 OnAfterPossibleChange(); 625 OnAfterPossibleChange();
623 } 626 }
624 627
625 void TextField::Edit::OnMouseLeave() { 628 void TextField::Edit::OnMouseLeave() {
626 SetContainsMouse(false); 629 SetContainsMouse(false);
627 } 630 }
628 631
632 LRESULT TextField::Edit::OnMouseWheel(UINT message,
633 WPARAM w_param, LPARAM l_param) {
634 // Reroute the mouse-wheel to the window under the mouse pointer if
635 // applicable.
636 if (views::RerouteMouseWheel(m_hWnd, w_param, l_param))
637 return 0;
638 return DefWindowProc(message, w_param, l_param);;
639 }
640
629 void TextField::Edit::OnMouseMove(UINT keys, const CPoint& point) { 641 void TextField::Edit::OnMouseMove(UINT keys, const CPoint& point) {
630 SetContainsMouse(true); 642 SetContainsMouse(true);
631 // Clamp the selection to the visible text so the user can't drag to select 643 // Clamp the selection to the visible text so the user can't drag to select
632 // the "phantom newline". In theory we could achieve this by clipping the X 644 // the "phantom newline". In theory we could achieve this by clipping the X
633 // coordinate, but in practice the edit seems to behave nondeterministically 645 // coordinate, but in practice the edit seems to behave nondeterministically
634 // with similar sequences of clipped input coordinates fed to it. Maybe it's 646 // with similar sequences of clipped input coordinates fed to it. Maybe it's
635 // reading the mouse cursor position directly? 647 // reading the mouse cursor position directly?
636 // 648 //
637 // This solution has a minor visual flaw, however: if there's a visible 649 // This solution has a minor visual flaw, however: if there's a visible
638 // cursor at the edge of the text (only true when there's no selection), 650 // cursor at the edge of the text (only true when there's no selection),
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 1155
1144 COLORREF bg_color; 1156 COLORREF bg_color;
1145 if (!use_default_background_color_) 1157 if (!use_default_background_color_)
1146 bg_color = skia::SkColorToCOLORREF(background_color_); 1158 bg_color = skia::SkColorToCOLORREF(background_color_);
1147 else 1159 else
1148 bg_color = GetSysColor(read_only_ ? COLOR_3DFACE : COLOR_WINDOW); 1160 bg_color = GetSysColor(read_only_ ? COLOR_3DFACE : COLOR_WINDOW);
1149 edit_->SetBackgroundColor(bg_color); 1161 edit_->SetBackgroundColor(bg_color);
1150 } 1162 }
1151 1163
1152 } // namespace views 1164 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | chrome/views/view_unittest.cc » ('j') | chrome/views/view_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698