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

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

Issue 135863002: Reland Merge NativeTextfieldViews into views::Textfield. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle Ctrl-Shift-Delete and Backspace on Linux, like on ChromeOS. Created 6 years, 11 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ 5 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_
6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "base/time/time.h" 15 #include "base/timer/timer.h"
16 #include "build/build_config.h"
17 #include "third_party/skia/include/core/SkColor.h" 16 #include "third_party/skia/include/core/SkColor.h"
17 #include "ui/base/ime/text_input_client.h"
18 #include "ui/base/ime/text_input_type.h" 18 #include "ui/base/ime/text_input_type.h"
19 #include "ui/base/models/simple_menu_model.h"
20 #include "ui/base/touch/touch_editing_controller.h"
19 #include "ui/events/keycodes/keyboard_codes.h" 21 #include "ui/events/keycodes/keyboard_codes.h"
20 #include "ui/gfx/font_list.h" 22 #include "ui/gfx/font_list.h"
21 #include "ui/gfx/native_widget_types.h" 23 #include "ui/gfx/range/range.h"
22 #include "ui/gfx/selection_model.h" 24 #include "ui/gfx/selection_model.h"
23 #include "ui/gfx/text_constants.h" 25 #include "ui/gfx/text_constants.h"
26 #include "ui/views/context_menu_controller.h"
27 #include "ui/views/controls/textfield/textfield_views_model.h"
28 #include "ui/views/drag_controller.h"
24 #include "ui/views/view.h" 29 #include "ui/views/view.h"
25 30
26 #if !defined(OS_LINUX)
27 #include "base/logging.h"
28 #endif
29
30 namespace gfx {
31 class Range;
32 class ImageSkia;
33 }
34
35 namespace ui {
36 class TextInputClient;
37 } // namespace ui
38
39 namespace views { 31 namespace views {
40 32
41 class ImageView; 33 class MenuRunner;
42 class NativeTextfieldViews;
43 class Painter; 34 class Painter;
44 class TextfieldController; 35 class TextfieldController;
45 36
46 // This class implements a View that wraps a native text (edit) field. 37 // A views/skia textfield implementation. No platform-specific code is used.
47 class VIEWS_EXPORT Textfield : public View { 38 class VIEWS_EXPORT Textfield : public View,
39 public TextfieldViewsModel::Delegate,
40 public ContextMenuController,
41 public DragController,
42 public ui::TouchEditable,
43 public ui::TextInputClient {
48 public: 44 public:
49 // The textfield's class name. 45 // The textfield's class name.
50 static const char kViewClassName[]; 46 static const char kViewClassName[];
51 47
52 enum StyleFlags { 48 enum StyleFlags {
53 STYLE_DEFAULT = 0, 49 STYLE_DEFAULT = 0,
54 STYLE_OBSCURED = 1 << 0, 50 STYLE_OBSCURED = 1 << 0,
55 STYLE_LOWERCASE = 1 << 1 51 STYLE_LOWERCASE = 1 << 1
56 }; 52 };
57 53
(...skipping 10 matching lines...) Expand all
68 64
69 // Gets/Sets whether or not the Textfield is read-only. 65 // Gets/Sets whether or not the Textfield is read-only.
70 bool read_only() const { return read_only_; } 66 bool read_only() const { return read_only_; }
71 void SetReadOnly(bool read_only); 67 void SetReadOnly(bool read_only);
72 68
73 // Gets/sets the STYLE_OBSCURED bit, controlling whether characters in this 69 // Gets/sets the STYLE_OBSCURED bit, controlling whether characters in this
74 // Textfield are displayed as asterisks/bullets. 70 // Textfield are displayed as asterisks/bullets.
75 bool IsObscured() const; 71 bool IsObscured() const;
76 void SetObscured(bool obscured); 72 void SetObscured(bool obscured);
77 73
78 // Gets/sets the duration to reveal the last typed char when the obscured bit 74 // Sets the input type of this textfield.
79 // is set. A duration of zero effectively disables the feature. Other values
80 // cause the last typed char to be shown for the defined duration. Note this
81 // only works with NativeTextfieldViews.
82 const base::TimeDelta& obscured_reveal_duration() const {
83 return obscured_reveal_duration_;
84 }
85 void set_obscured_reveal_duration(const base::TimeDelta& duration) {
86 obscured_reveal_duration_ = duration;
87 }
88
89 // Gets/Sets the input type of this textfield.
90 ui::TextInputType GetTextInputType() const;
91 void SetTextInputType(ui::TextInputType type); 75 void SetTextInputType(ui::TextInputType type);
92 76
93 // Gets/Sets the text currently displayed in the Textfield. 77 // Gets the text currently displayed in the Textfield.
94 const base::string16& text() const { return text_; } 78 const base::string16& text() const { return model_->text(); }
95 79
96 // Sets the text currently displayed in the Textfield. This doesn't 80 // Sets the text currently displayed in the Textfield. This doesn't
97 // change the cursor position if the current cursor is within the 81 // change the cursor position if the current cursor is within the
98 // new text's range, or moves the cursor to the end if the cursor is 82 // new text's range, or moves the cursor to the end if the cursor is
99 // out of the new text's range. 83 // out of the new text's range.
100 void SetText(const base::string16& text); 84 void SetText(const base::string16& new_text);
101 85
102 // Appends the given string to the previously-existing text in the field. 86 // Appends the given string to the previously-existing text in the field.
103 void AppendText(const base::string16& text); 87 void AppendText(const base::string16& new_text);
104 88
105 // Inserts |text| at the current cursor position, replacing any selected text. 89 // Inserts |new_text| at the cursor position, replacing any selected text.
106 void InsertOrReplaceText(const base::string16& text); 90 void InsertOrReplaceText(const base::string16& new_text);
107 91
108 // Returns the text direction. 92 // Returns the text direction.
109 base::i18n::TextDirection GetTextDirection() const; 93 base::i18n::TextDirection GetTextDirection() const;
110 94
111 // Returns the text that is currently selected. 95 // Returns the text that is currently selected.
112 base::string16 GetSelectedText() const; 96 base::string16 GetSelectedText() const;
113 97
114 // Select the entire text range. If |reversed| is true, the range will end at 98 // Select the entire text range. If |reversed| is true, the range will end at
115 // the logical beginning of the text; this generally shows the leading portion 99 // the logical beginning of the text; this generally shows the leading portion
116 // of text that overflows its display area. 100 // of text that overflows its display area.
117 void SelectAll(bool reversed); 101 void SelectAll(bool reversed);
118 102
119 // Clears the selection within the edit field and sets the caret to the end. 103 // Clears the selection within the edit field and sets the caret to the end.
120 void ClearSelection() const; 104 void ClearSelection();
121 105
122 // Checks if there is any selected text. 106 // Checks if there is any selected text.
123 bool HasSelection() const; 107 bool HasSelection() const;
124 108
125 // Accessor for |style_|. 109 // Accessor for |style_|.
126 StyleFlags style() const { return style_; } 110 StyleFlags style() const { return style_; }
127 111
128 // Gets/Sets the text color to be used when painting the Textfield. 112 // Gets/Sets the text color to be used when painting the Textfield.
129 // Call |UseDefaultTextColor| to restore the default system color. 113 // Call |UseDefaultTextColor| to restore the default system color.
130 SkColor GetTextColor() const; 114 SkColor GetTextColor() const;
131 void SetTextColor(SkColor color); 115 void SetTextColor(SkColor color);
132 void UseDefaultTextColor(); 116 void UseDefaultTextColor();
133 117
134 // Gets/Sets the background color to be used when painting the Textfield. 118 // Gets/Sets the background color to be used when painting the Textfield.
135 // Call |UseDefaultBackgroundColor| to restore the default system color. 119 // Call |UseDefaultBackgroundColor| to restore the default system color.
136 SkColor GetBackgroundColor() const; 120 SkColor GetBackgroundColor() const;
137 void SetBackgroundColor(SkColor color); 121 void SetBackgroundColor(SkColor color);
138 void UseDefaultBackgroundColor(); 122 void UseDefaultBackgroundColor();
139 123
140 // Gets/Sets whether or not the cursor is enabled. 124 // Gets/Sets whether or not the cursor is enabled.
141 bool GetCursorEnabled() const; 125 bool GetCursorEnabled() const;
142 void SetCursorEnabled(bool enabled); 126 void SetCursorEnabled(bool enabled);
143 127
144 // Gets/Sets the fonts used when rendering the text within the Textfield. 128 // Gets/Sets the fonts used when rendering the text within the Textfield.
145 const gfx::FontList& font_list() const { return font_list_; } 129 const gfx::FontList& GetFontList() const;
146 void SetFontList(const gfx::FontList& font_list); 130 void SetFontList(const gfx::FontList& font_list);
147 const gfx::Font& GetPrimaryFont() const;
148 void SetFont(const gfx::Font& font);
149
150 // Sets the left and right margin (in pixels) within the text box. On Windows
151 // this is accomplished by packing the left and right margin into a single
152 // 32 bit number, so the left and right margins are effectively 16 bits.
153 void SetHorizontalMargins(int left, int right);
154
155 // Sets the top and bottom margins (in pixels) within the textfield.
156 // NOTE: in most cases height could be changed instead.
157 void SetVerticalMargins(int top, int bottom);
158 131
159 // Sets the default width of the text control. See default_width_in_chars_. 132 // Sets the default width of the text control. See default_width_in_chars_.
160 void set_default_width_in_chars(int default_width) { 133 void set_default_width_in_chars(int default_width) {
161 default_width_in_chars_ = default_width; 134 default_width_in_chars_ = default_width;
162 } 135 }
163 136
164 // Removes the border from the edit box, giving it a 2D look.
165 bool draw_border() const { return draw_border_; }
166 void RemoveBorder();
167
168 // Sets the text to display when empty. 137 // Sets the text to display when empty.
169 void set_placeholder_text(const base::string16& text) { 138 void set_placeholder_text(const base::string16& text) {
170 placeholder_text_ = text; 139 placeholder_text_ = text;
171 } 140 }
172 virtual base::string16 GetPlaceholderText() const; 141 virtual base::string16 GetPlaceholderText() const;
173 142
174 SkColor placeholder_text_color() const { return placeholder_text_color_; } 143 SkColor placeholder_text_color() const { return placeholder_text_color_; }
175 void set_placeholder_text_color(SkColor color) { 144 void set_placeholder_text_color(SkColor color) {
176 placeholder_text_color_ = color; 145 placeholder_text_color_ = color;
177 } 146 }
178 147
179 // Getter for the horizontal margins that were set. Returns false if
180 // horizontal margins weren't set.
181 bool GetHorizontalMargins(int* left, int* right);
182
183 // Getter for the vertical margins that were set. Returns false if vertical
184 // margins weren't set.
185 bool GetVerticalMargins(int* top, int* bottom);
186
187 // Updates all properties on the textfield. This is invoked internally.
188 // Users of Textfield never need to invoke this directly.
189 void UpdateAllProperties();
190
191 // Invoked by the edit control when the value changes. This method set
192 // the text_ member variable to the value contained in edit control.
193 // This is important because the edit control can be replaced if it has
194 // been deleted during a window close.
195 void SyncText();
196
197 // Returns whether or not an IME is composing text. 148 // Returns whether or not an IME is composing text.
198 bool IsIMEComposing() const; 149 bool IsIMEComposing() const;
199 150
200 // Gets the selected logical text range. 151 // Gets the selected logical text range.
201 const gfx::Range& GetSelectedRange() const; 152 const gfx::Range& GetSelectedRange() const;
202 153
203 // Selects the specified logical text range. 154 // Selects the specified logical text range.
204 void SelectRange(const gfx::Range& range); 155 void SelectRange(const gfx::Range& range);
205 156
206 // Gets the text selection model. 157 // Gets the text selection model.
(...skipping 20 matching lines...) Expand all
227 void ClearEditHistory(); 178 void ClearEditHistory();
228 179
229 // Set the accessible name of the text field. 180 // Set the accessible name of the text field.
230 void SetAccessibleName(const base::string16& name); 181 void SetAccessibleName(const base::string16& name);
231 182
232 // Performs the action associated with the specified command id. 183 // Performs the action associated with the specified command id.
233 void ExecuteCommand(int command_id); 184 void ExecuteCommand(int command_id);
234 185
235 void SetFocusPainter(scoped_ptr<Painter> focus_painter); 186 void SetFocusPainter(scoped_ptr<Painter> focus_painter);
236 187
237 // Provided only for testing:
238 NativeTextfieldViews* GetTextfieldViewForTesting() const {
239 return textfield_view_;
240 }
241
242 // Returns whether there is a drag operation originating from the textfield. 188 // Returns whether there is a drag operation originating from the textfield.
243 bool HasTextBeingDragged(); 189 bool HasTextBeingDragged();
244 190
245 // Overridden from View: 191 // View overrides:
246 virtual void Layout() OVERRIDE; 192 // TODO(msw): Match declaration and definition order to View.
247 virtual int GetBaseline() const OVERRIDE; 193 virtual int GetBaseline() const OVERRIDE;
248 virtual gfx::Size GetPreferredSize() OVERRIDE; 194 virtual gfx::Size GetPreferredSize() OVERRIDE;
249 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; 195 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE;
250 virtual bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) OVERRIDE; 196 virtual bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) OVERRIDE;
251 virtual void OnEnabledChanged() OVERRIDE; 197 virtual void OnEnabledChanged() OVERRIDE;
252 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 198 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
253 virtual bool OnKeyPressed(const ui::KeyEvent& e) OVERRIDE; 199 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
254 virtual bool OnKeyReleased(const ui::KeyEvent& e) OVERRIDE; 200 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
255 virtual bool OnMouseDragged(const ui::MouseEvent& e) OVERRIDE; 201 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
202 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
256 virtual void OnFocus() OVERRIDE; 203 virtual void OnFocus() OVERRIDE;
257 virtual void OnBlur() OVERRIDE; 204 virtual void OnBlur() OVERRIDE;
258 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; 205 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
259 virtual ui::TextInputClient* GetTextInputClient() OVERRIDE; 206 virtual ui::TextInputClient* GetTextInputClient() OVERRIDE;
260 virtual gfx::Point GetKeyboardContextMenuLocation() OVERRIDE; 207 virtual gfx::Point GetKeyboardContextMenuLocation() OVERRIDE;
208 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE;
209 virtual const char* GetClassName() const OVERRIDE;
210 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event) OVERRIDE;
211 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
212 virtual bool GetDropFormats(
213 int* formats,
214 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE;
215 virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE;
216 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE;
217 virtual void OnDragExited() OVERRIDE;
218 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE;
219 virtual void OnDragDone() OVERRIDE;
220 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
221
222 // TextfieldViewsModel::Delegate overrides:
223 virtual void OnCompositionTextConfirmedOrCleared() OVERRIDE;
224
225 // ContextMenuController overrides:
226 virtual void ShowContextMenuForView(View* source,
227 const gfx::Point& point,
228 ui::MenuSourceType source_type) OVERRIDE;
229
230 // DragController overrides:
231 virtual void WriteDragDataForView(View* sender,
232 const gfx::Point& press_pt,
233 ui::OSExchangeData* data) OVERRIDE;
234 virtual int GetDragOperationsForView(View* sender,
235 const gfx::Point& p) OVERRIDE;
236 virtual bool CanStartDragForView(View* sender,
237 const gfx::Point& press_pt,
238 const gfx::Point& p) OVERRIDE;
239
240 // ui::TouchEditable overrides:
241 virtual void SelectRect(const gfx::Point& start,
242 const gfx::Point& end) OVERRIDE;
243 virtual void MoveCaretTo(const gfx::Point& point) OVERRIDE;
244 virtual void GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) OVERRIDE;
245 virtual gfx::Rect GetBounds() OVERRIDE;
246 virtual gfx::NativeView GetNativeView() const OVERRIDE;
247 virtual void ConvertPointToScreen(gfx::Point* point) OVERRIDE;
248 virtual void ConvertPointFromScreen(gfx::Point* point) OVERRIDE;
249 virtual bool DrawsHandles() OVERRIDE;
250 virtual void OpenContextMenu(const gfx::Point& anchor) OVERRIDE;
251
252 // ui::SimpleMenuModel::Delegate overrides:
253 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
254 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
255 virtual bool GetAcceleratorForCommandId(
256 int command_id,
257 ui::Accelerator* accelerator) OVERRIDE;
258 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
259
260 // ui::TextInputClient overrides:
261 virtual void SetCompositionText(
262 const ui::CompositionText& composition) OVERRIDE;
263 virtual void ConfirmCompositionText() OVERRIDE;
264 virtual void ClearCompositionText() OVERRIDE;
265 virtual void InsertText(const base::string16& text) OVERRIDE;
266 virtual void InsertChar(base::char16 ch, int flags) OVERRIDE;
267 virtual gfx::NativeWindow GetAttachedWindow() const OVERRIDE;
268 virtual ui::TextInputType GetTextInputType() const OVERRIDE;
269 virtual ui::TextInputMode GetTextInputMode() const OVERRIDE;
270 virtual bool CanComposeInline() const OVERRIDE;
271 virtual gfx::Rect GetCaretBounds() const OVERRIDE;
272 virtual bool GetCompositionCharacterBounds(uint32 index,
273 gfx::Rect* rect) const OVERRIDE;
274 virtual bool HasCompositionText() const OVERRIDE;
275 virtual bool GetTextRange(gfx::Range* range) const OVERRIDE;
276 virtual bool GetCompositionTextRange(gfx::Range* range) const OVERRIDE;
277 virtual bool GetSelectionRange(gfx::Range* range) const OVERRIDE;
278 virtual bool SetSelectionRange(const gfx::Range& range) OVERRIDE;
279 virtual bool DeleteRange(const gfx::Range& range) OVERRIDE;
280 virtual bool GetTextFromRange(const gfx::Range& range,
281 base::string16* text) const OVERRIDE;
282 virtual void OnInputMethodChanged() OVERRIDE;
283 virtual bool ChangeTextDirectionAndLayoutAlignment(
284 base::i18n::TextDirection direction) OVERRIDE;
285 virtual void ExtendSelectionAndDelete(size_t before, size_t after) OVERRIDE;
286 virtual void EnsureCaretInRect(const gfx::Rect& rect) OVERRIDE;
287 virtual void OnCandidateWindowShown() OVERRIDE;
288 virtual void OnCandidateWindowUpdated() OVERRIDE;
289 virtual void OnCandidateWindowHidden() OVERRIDE;
261 290
262 protected: 291 protected:
263 virtual void ViewHierarchyChanged( 292 // Returns the TextfieldViewsModel's text/cursor/selection rendering model.
264 const ViewHierarchyChangedDetails& details) OVERRIDE; 293 gfx::RenderText* GetRenderText() const;
265 virtual const char* GetClassName() const OVERRIDE;
266
267 // The object that actually implements the native textfield view.
268 // TODO(msw): Merge views::NativeTextfieldViews and views::Textfield classes.
269 NativeTextfieldViews* textfield_view_;
270 294
271 private: 295 private:
272 // Returns the insets to the rectangle where text is actually painted. 296 friend class TextfieldTest;
273 gfx::Insets GetTextInsets() const; 297 friend class TouchSelectionControllerImplTest;
298
299 // Converts the raw text according to the current style, e.g. STYLE_LOWERCASE.
300 base::string16 GetTextForDisplay(const base::string16& raw);
274 301
275 // Handles a request to change the value of this text field from software 302 // Handles a request to change the value of this text field from software
276 // using an accessibility API (typically automation software, screen readers 303 // using an accessibility API (typically automation software, screen readers
277 // don't normally use this). Sets the value and clears the selection. 304 // don't normally use this). Sets the value and clears the selection.
278 void AccessibilitySetValue(const base::string16& new_value); 305 void AccessibilitySetValue(const base::string16& new_value);
279 306
307 // Updates the painted background color.
308 void UpdateBackgroundColor();
309
310 // Updates any colors that have not been explicitly set from the theme.
311 void UpdateColorsFromTheme(const ui::NativeTheme* theme);
312
313 // Does necessary updates when the text and/or cursor position changes.
314 void UpdateAfterChange(bool text_changed, bool cursor_changed);
315
316 // A callback function to periodically update the cursor state.
317 void UpdateCursor();
318
319 // Repaint the cursor.
320 void RepaintCursor();
321
322 void PaintTextAndCursor(gfx::Canvas* canvas);
323
324 // Helper function to call MoveCursorTo on the TextfieldViewsModel.
325 bool MoveCursorTo(const gfx::Point& point, bool select);
326
327 // Convenience method to call InputMethod::OnCaretBoundsChanged();
328 void OnCaretBoundsChanged();
329
330 // Convenience method to call TextfieldController::OnBeforeUserAction();
331 void OnBeforeUserAction();
332
333 // Convenience method to call TextfieldController::OnAfterUserAction();
334 void OnAfterUserAction();
335
336 // Calls |model_->Cut()| and notifies TextfieldController on success.
337 bool Cut();
338
339 // Calls |model_->Copy()| and notifies TextfieldController on success.
340 bool Copy();
341
342 // Calls |model_->Paste()| and calls TextfieldController::ContentsChanged()
343 // explicitly if paste succeeded.
344 bool Paste();
345
346 // Utility function to prepare the context menu.
347 void UpdateContextMenu();
348
349 // Tracks the mouse clicks for single/double/triple clicks.
350 void TrackMouseClicks(const ui::MouseEvent& event);
351
352 // Returns true if the current text input type allows access by the IME.
353 bool ImeEditingAllowed() const;
354
355 // Reveals the obscured char at |index| for the given |duration|. If |index|
356 // is -1, existing revealed index will be cleared.
357 void RevealObscuredChar(int index, const base::TimeDelta& duration);
358
359 void CreateTouchSelectionControllerAndNotifyIt();
360
361 // The text model.
362 scoped_ptr<TextfieldViewsModel> model_;
363
280 // This is the current listener for events from this Textfield. 364 // This is the current listener for events from this Textfield.
281 TextfieldController* controller_; 365 TextfieldController* controller_;
282 366
283 // The mask of style options for this Textfield. 367 // The mask of style options for this Textfield.
284 StyleFlags style_; 368 StyleFlags style_;
285 369
286 // The fonts used to render the text in the Textfield.
287 gfx::FontList font_list_;
288
289 // The text displayed in the Textfield.
290 base::string16 text_;
291
292 // True if this Textfield cannot accept input and is read-only. 370 // True if this Textfield cannot accept input and is read-only.
293 bool read_only_; 371 bool read_only_;
294 372
295 // The default number of average characters for the width of this text field. 373 // The default number of average characters for the width of this text field.
296 // This will be reported as the "desired size". Defaults to 0. 374 // This will be reported as the "desired size". Defaults to 0.
297 int default_width_in_chars_; 375 int default_width_in_chars_;
298 376
299 // Whether the border is drawn. 377 scoped_ptr<Painter> focus_painter_;
300 bool draw_border_;
301 378
302 // Text color. Only used if |use_default_text_color_| is false. 379 // Text color. Only used if |use_default_text_color_| is false.
303 SkColor text_color_; 380 SkColor text_color_;
304 381
305 // Should we use the system text color instead of |text_color_|? 382 // Should we use the system text color instead of |text_color_|?
306 bool use_default_text_color_; 383 bool use_default_text_color_;
307 384
308 // Background color. Only used if |use_default_background_color_| is false. 385 // Background color. Only used if |use_default_background_color_| is false.
309 SkColor background_color_; 386 SkColor background_color_;
310 387
311 // Should we use the system background color instead of |background_color_|? 388 // Should we use the system background color instead of |background_color_|?
312 bool use_default_background_color_; 389 bool use_default_background_color_;
313 390
314 // Holds inner textfield margins.
315 gfx::Insets margins_;
316
317 // Holds whether margins were set.
318 bool horizontal_margins_were_set_;
319 bool vertical_margins_were_set_;
320
321 // Text to display when empty. 391 // Text to display when empty.
322 base::string16 placeholder_text_; 392 base::string16 placeholder_text_;
323 393
324 // Placeholder text color. 394 // Placeholder text color.
325 SkColor placeholder_text_color_; 395 SkColor placeholder_text_color_;
326 396
327 // The accessible name of the text field. 397 // The accessible name of the text field.
328 base::string16 accessible_name_; 398 base::string16 accessible_name_;
329 399
330 // The input type of this text field. 400 // The input type of this text field.
331 ui::TextInputType text_input_type_; 401 ui::TextInputType text_input_type_;
332 402
333 // The duration to reveal the last typed char for obscured textfields. 403 // The duration to reveal the last typed char for obscured textfields.
334 base::TimeDelta obscured_reveal_duration_; 404 base::TimeDelta obscured_reveal_duration_;
335 405
406 // True if InputMethod::CancelComposition() should not be called.
407 bool skip_input_method_cancel_composition_;
408
409 // The text editing cursor repaint timer and visibility.
410 base::RepeatingTimer<Textfield> cursor_repaint_timer_;
411 bool is_cursor_visible_;
412
413 // The drop cursor is a visual cue for where dragged text will be dropped.
414 bool is_drop_cursor_visible_;
415 gfx::SelectionModel drop_cursor_position_;
416
417 // Is the user potentially dragging and dropping from this view?
418 bool initiating_drag_;
419
420 // State variables used to track double and triple clicks.
421 size_t aggregated_clicks_;
422 base::TimeDelta last_click_time_;
423 gfx::Point last_click_location_;
424 gfx::Range double_click_word_;
425
426 scoped_ptr<ui::TouchSelectionController> touch_selection_controller_;
427
428 // A timer to control the duration of showing the last typed char in
429 // obscured text. When the timer is running, the last typed char is shown
430 // and when the time expires, the last typed char is obscured.
431 base::OneShotTimer<Textfield> obscured_reveal_timer_;
432
433 // Context menu related members.
434 scoped_ptr<ui::SimpleMenuModel> context_menu_contents_;
435 scoped_ptr<views::MenuRunner> context_menu_runner_;
436
336 // Used to bind callback functions to this object. 437 // Used to bind callback functions to this object.
337 base::WeakPtrFactory<Textfield> weak_ptr_factory_; 438 base::WeakPtrFactory<Textfield> weak_ptr_factory_;
338 439
339 scoped_ptr<Painter> focus_painter_;
340
341 DISALLOW_COPY_AND_ASSIGN(Textfield); 440 DISALLOW_COPY_AND_ASSIGN(Textfield);
342 }; 441 };
343 442
344 } // namespace views 443 } // namespace views
345 444
346 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ 445 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/native_textfield_views_unittest.cc ('k') | ui/views/controls/textfield/textfield.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698