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 #ifndef VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WIN_H_ | 5 #ifndef VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WIN_H_ |
6 #define VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WIN_H_ | 6 #define VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WIN_H_ |
7 | 7 |
8 #include <atlbase.h> | 8 #include <atlbase.h> |
9 #include <atlapp.h> | 9 #include <atlapp.h> |
10 #include <atlcrack.h> | 10 #include <atlcrack.h> |
11 #include <atlctrls.h> | 11 #include <atlctrls.h> |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 ScopedFreeze(NativeTextfieldWin* edit, ITextDocument* text_object_model); | 111 ScopedFreeze(NativeTextfieldWin* edit, ITextDocument* text_object_model); |
112 ~ScopedFreeze(); | 112 ~ScopedFreeze(); |
113 | 113 |
114 private: | 114 private: |
115 NativeTextfieldWin* const edit_; | 115 NativeTextfieldWin* const edit_; |
116 ITextDocument* const text_object_model_; | 116 ITextDocument* const text_object_model_; |
117 | 117 |
118 DISALLOW_COPY_AND_ASSIGN(ScopedFreeze); | 118 DISALLOW_COPY_AND_ASSIGN(ScopedFreeze); |
119 }; | 119 }; |
120 | 120 |
| 121 // This object suspends placing any operations on the edit's undo stack until |
| 122 // the object is destroyed. If we don't do this, some of the operations we |
| 123 // perform behind the user's back will be undoable by the user, which feels |
| 124 // bizarre and confusing. |
| 125 class ScopedSuspendUndo { |
| 126 public: |
| 127 explicit ScopedSuspendUndo(ITextDocument* text_object_model); |
| 128 ~ScopedSuspendUndo(); |
| 129 |
| 130 private: |
| 131 ITextDocument* const text_object_model_; |
| 132 |
| 133 DISALLOW_COPY_AND_ASSIGN(ScopedSuspendUndo); |
| 134 }; |
| 135 |
121 // message handlers | 136 // message handlers |
122 void OnChar(TCHAR key, UINT repeat_count, UINT flags); | 137 void OnChar(TCHAR key, UINT repeat_count, UINT flags); |
123 void OnContextMenu(HWND window, const POINT& point); | 138 void OnContextMenu(HWND window, const POINT& point); |
124 void OnCopy(); | 139 void OnCopy(); |
125 void OnCut(); | 140 void OnCut(); |
126 LRESULT OnImeChar(UINT message, WPARAM wparam, LPARAM lparam); | 141 LRESULT OnImeChar(UINT message, WPARAM wparam, LPARAM lparam); |
127 LRESULT OnImeStartComposition(UINT message, WPARAM wparam, LPARAM lparam); | 142 LRESULT OnImeStartComposition(UINT message, WPARAM wparam, LPARAM lparam); |
128 LRESULT OnImeComposition(UINT message, WPARAM wparam, LPARAM lparam); | 143 LRESULT OnImeComposition(UINT message, WPARAM wparam, LPARAM lparam); |
129 LRESULT OnImeEndComposition(UINT message, WPARAM wparam, LPARAM lparam); | 144 LRESULT OnImeEndComposition(UINT message, WPARAM wparam, LPARAM lparam); |
130 void OnKeyDown(TCHAR key, UINT repeat_count, UINT flags); | 145 void OnKeyDown(TCHAR key, UINT repeat_count, UINT flags); |
(...skipping 11 matching lines...) Expand all Loading... |
142 void OnSysChar(TCHAR ch, UINT repeat_count, UINT flags); | 157 void OnSysChar(TCHAR ch, UINT repeat_count, UINT flags); |
143 | 158 |
144 // Helper function for OnChar() and OnKeyDown() that handles keystrokes that | 159 // Helper function for OnChar() and OnKeyDown() that handles keystrokes that |
145 // could change the text in the edit. | 160 // could change the text in the edit. |
146 void HandleKeystroke(UINT message, TCHAR key, UINT repeat_count, UINT flags); | 161 void HandleKeystroke(UINT message, TCHAR key, UINT repeat_count, UINT flags); |
147 | 162 |
148 // Every piece of code that can change the edit should call these functions | 163 // Every piece of code that can change the edit should call these functions |
149 // before and after the change. These functions determine if anything | 164 // before and after the change. These functions determine if anything |
150 // meaningful changed, and do any necessary updating and notification. | 165 // meaningful changed, and do any necessary updating and notification. |
151 void OnBeforePossibleChange(); | 166 void OnBeforePossibleChange(); |
152 void OnAfterPossibleChange(); | 167 |
| 168 // When a user types a BIDI mirroring character (e.g. left parenthesis |
| 169 // U+0028, which should be rendered as '(' in LTR context unless surrounded |
| 170 // by RTL characters in both sides, and it should be rendered as ')' in RTL |
| 171 // context unless surrounded by LTR characters in both sides.), the textfield |
| 172 // does not properly mirror the character when necessary. However, if we |
| 173 // explicitly set the text in the edit to the entire current string, then |
| 174 // the BIDI mirroring characters will be mirrored properly. When |
| 175 // |should_redraw_text| is true, we explicitly set the text in the edit to |
| 176 // the entire current string any time the text changes. |
| 177 void OnAfterPossibleChange(bool should_redraw_text); |
153 | 178 |
154 // Given an X coordinate in client coordinates, returns that coordinate | 179 // Given an X coordinate in client coordinates, returns that coordinate |
155 // clipped to be within the horizontal bounds of the visible text. | 180 // clipped to be within the horizontal bounds of the visible text. |
156 // | 181 // |
157 // This is used in our mouse handlers to work around quirky behaviors of the | 182 // This is used in our mouse handlers to work around quirky behaviors of the |
158 // underlying CRichEditCtrl like not supporting triple-click when the user | 183 // underlying CRichEditCtrl like not supporting triple-click when the user |
159 // doesn't click on the text itself. | 184 // doesn't click on the text itself. |
160 // | 185 // |
161 // |is_triple_click| should be true iff this is the third click of a triple | 186 // |is_triple_click| should be true iff this is the third click of a triple |
162 // click. Sadly, we need to clip slightly differently in this case. | 187 // click. Sadly, we need to clip slightly differently in this case. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 NativeViewHost* container_view_; | 241 NativeViewHost* container_view_; |
217 | 242 |
218 COLORREF bg_color_; | 243 COLORREF bg_color_; |
219 | 244 |
220 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldWin); | 245 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldWin); |
221 }; | 246 }; |
222 | 247 |
223 } // namespace views | 248 } // namespace views |
224 | 249 |
225 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WIN_H_ | 250 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WIN_H_ |
OLD | NEW |