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

Side by Side Diff: views/controls/textfield/native_textfield_views.h

Issue 7265011: RenderText API Outline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Almost at parity with the current implementation. Created 9 years, 5 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
OLDNEW
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 #ifndef VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ 5 #ifndef VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_
6 #define VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ 6 #define VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/task.h" 10 #include "base/task.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 virtual gfx::NativeView GetTestingHandle() const OVERRIDE; 107 virtual gfx::NativeView GetTestingHandle() const OVERRIDE;
108 virtual bool IsIMEComposing() const OVERRIDE; 108 virtual bool IsIMEComposing() const OVERRIDE;
109 virtual void GetSelectedRange(ui::Range* range) const OVERRIDE; 109 virtual void GetSelectedRange(ui::Range* range) const OVERRIDE;
110 virtual void SelectRange(const ui::Range& range) OVERRIDE; 110 virtual void SelectRange(const ui::Range& range) OVERRIDE;
111 virtual size_t GetCursorPosition() const OVERRIDE; 111 virtual size_t GetCursorPosition() const OVERRIDE;
112 virtual bool HandleKeyPressed(const KeyEvent& e) OVERRIDE; 112 virtual bool HandleKeyPressed(const KeyEvent& e) OVERRIDE;
113 virtual bool HandleKeyReleased(const KeyEvent& e) OVERRIDE; 113 virtual bool HandleKeyReleased(const KeyEvent& e) OVERRIDE;
114 virtual void HandleFocus() OVERRIDE; 114 virtual void HandleFocus() OVERRIDE;
115 virtual void HandleBlur() OVERRIDE; 115 virtual void HandleBlur() OVERRIDE;
116 virtual TextInputClient* GetTextInputClient() OVERRIDE; 116 virtual TextInputClient* GetTextInputClient() OVERRIDE;
117 virtual TextStyle* CreateTextStyle() OVERRIDE; 117 virtual void ApplyStyleRange(const gfx::StyleRange& style) OVERRIDE;
118 virtual void ApplyTextStyle(const TextStyle* style, 118 virtual void ApplyDefaultStyle() OVERRIDE;
119 const ui::Range& range) OVERRIDE;
120 virtual void ClearAllTextStyles() OVERRIDE;
121 virtual void ClearEditHistory() OVERRIDE; 119 virtual void ClearEditHistory() OVERRIDE;
122 120
123 // ui::SimpleMenuModel::Delegate overrides 121 // ui::SimpleMenuModel::Delegate overrides
124 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; 122 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
125 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; 123 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
126 virtual bool GetAcceleratorForCommandId( 124 virtual bool GetAcceleratorForCommandId(
127 int command_id, 125 int command_id,
128 ui::Accelerator* accelerator) OVERRIDE; 126 ui::Accelerator* accelerator) OVERRIDE;
129 virtual void ExecuteCommand(int command_id) OVERRIDE; 127 virtual void ExecuteCommand(int command_id) OVERRIDE;
130 128
(...skipping 26 matching lines...) Expand all
157 const ui::Range& range, 155 const ui::Range& range,
158 const base::Callback<void(const string16&)>& callback) OVERRIDE; 156 const base::Callback<void(const string16&)>& callback) OVERRIDE;
159 virtual void OnInputMethodChanged() OVERRIDE; 157 virtual void OnInputMethodChanged() OVERRIDE;
160 virtual bool ChangeTextDirectionAndLayoutAlignment( 158 virtual bool ChangeTextDirectionAndLayoutAlignment(
161 base::i18n::TextDirection direction) OVERRIDE; 159 base::i18n::TextDirection direction) OVERRIDE;
162 virtual View* GetOwnerViewOfTextInputClient() OVERRIDE; 160 virtual View* GetOwnerViewOfTextInputClient() OVERRIDE;
163 161
164 // Overridden from TextfieldViewsModel::Delegate: 162 // Overridden from TextfieldViewsModel::Delegate:
165 virtual void OnCompositionTextConfirmedOrCleared() OVERRIDE; 163 virtual void OnCompositionTextConfirmedOrCleared() OVERRIDE;
166 164
167 // Returns the Textfield's font. 165 // Returns the TextfieldViewsModel's text/cursor/selection rendering model.
168 const gfx::Font& GetFont() const; 166 gfx::RenderText* GetRenderText() const;
169
170 // Returns the Textfield's text color.
171 SkColor GetTextColor() const;
172 167
173 // A callback function to periodically update the cursor state. 168 // A callback function to periodically update the cursor state.
174 void UpdateCursor(); 169 void UpdateCursor();
175 170
176 // Repaint the cursor. 171 // Repaint the cursor.
177 void RepaintCursor(); 172 void RepaintCursor();
178 173
179 // Returns the bounds of character at the current cursor.
180 gfx::Rect GetCursorBounds(size_t cursor_pos, bool insert_mode) const;
181
182 // Update the cursor_bounds and text_offset. 174 // Update the cursor_bounds and text_offset.
183 void UpdateCursorBoundsAndTextOffset(size_t cursor_pos, bool insert_mode); 175 void UpdateCursorBoundsAndTextOffset(size_t cursor_pos, bool insert_mode);
184 176
185 void PaintTextAndCursor(gfx::Canvas* canvas); 177 void PaintTextAndCursor(gfx::Canvas* canvas);
186 178
187 // Handle the keyevent. 179 // Handle the keyevent.
188 bool HandleKeyEvent(const KeyEvent& key_event); 180 bool HandleKeyEvent(const KeyEvent& key_event);
189 181
190 // Find a cusor position for given |point| in this views coordinates.
191 size_t FindCursorPosition(const gfx::Point& point) const;
192
193 // Returns true if the local point is over the selected range of text. 182 // Returns true if the local point is over the selected range of text.
194 bool IsPointInSelection(const gfx::Point& point) const; 183 bool IsPointInSelection(const gfx::Point& point) const;
195 184
196 // Helper function to call MoveCursorTo on the TextfieldViewsModel. 185 // Helper function to call MoveCursorTo on the TextfieldViewsModel.
197 bool MoveCursorTo(const gfx::Point& point, bool select); 186 bool MoveCursorTo(const gfx::Point& point, bool select);
198 187
199 // Utility function to inform the parent textfield (and its controller if any) 188 // Utility function to inform the parent textfield (and its controller if any)
200 // that the text in the textfield has changed. 189 // that the text in the textfield has changed.
201 void PropagateTextChange(); 190 void PropagateTextChange();
202 191
(...skipping 26 matching lines...) Expand all
229 218
230 // The parent textfield, the owner of this object. 219 // The parent textfield, the owner of this object.
231 Textfield* textfield_; 220 Textfield* textfield_;
232 221
233 // The text model. 222 // The text model.
234 scoped_ptr<TextfieldViewsModel> model_; 223 scoped_ptr<TextfieldViewsModel> model_;
235 224
236 // The reference to the border class. The object is owned by View::border_. 225 // The reference to the border class. The object is owned by View::border_.
237 FocusableBorder* text_border_; 226 FocusableBorder* text_border_;
238 227
239 // The x offset for the text to be drawn, without insets;
240 int text_offset_;
241
242 // True if the textfield is in insert mode.
243 bool insert_;
244
245 // The local bounds and visibility of the textfield's text cursor. 228 // The local bounds and visibility of the textfield's text cursor.
246 gfx::Rect cursor_bounds_;
247 bool is_cursor_visible_; 229 bool is_cursor_visible_;
248
249 // The drop cursor is a visual cue for where dragged text will be dropped. 230 // The drop cursor is a visual cue for where dragged text will be dropped.
250 bool is_drop_cursor_visible_; 231 bool is_drop_cursor_visible_;
251 232
252 // True if InputMethod::CancelComposition() should not be called. 233 // True if InputMethod::CancelComposition() should not be called.
253 bool skip_input_method_cancel_composition_; 234 bool skip_input_method_cancel_composition_;
254 235
255 // Is the user potentially dragging and dropping from this view? 236 // Is the user potentially dragging and dropping from this view?
256 bool initiating_drag_; 237 bool initiating_drag_;
257 238
258 // A runnable method factory for callback to update the cursor. 239 // A runnable method factory for callback to update the cursor.
259 ScopedRunnableMethodFactory<NativeTextfieldViews> cursor_timer_; 240 ScopedRunnableMethodFactory<NativeTextfieldViews> cursor_timer_;
260 241
261 // State variables used to track double and triple clicks. 242 // State variables used to track double and triple clicks.
262 size_t aggregated_clicks_; 243 size_t aggregated_clicks_;
263 base::Time last_click_time_; 244 base::Time last_click_time_;
264 gfx::Point last_click_location_; 245 gfx::Point last_click_location_;
265 246
266 // Context menu and its content list for the textfield. 247 // Context menu and its content list for the textfield.
267 scoped_ptr<ui::SimpleMenuModel> context_menu_contents_; 248 scoped_ptr<ui::SimpleMenuModel> context_menu_contents_;
268 scoped_ptr<views::MenuModelAdapter> context_menu_delegate_; 249 scoped_ptr<views::MenuModelAdapter> context_menu_delegate_;
269 scoped_ptr<views::MenuItemView> context_menu_menu_; 250 scoped_ptr<views::MenuItemView> context_menu_menu_;
270 251
271 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews); 252 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews);
272 }; 253 };
273 254
274 } // namespace views 255 } // namespace views
275 256
276 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ 257 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698