| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_NATIVE_TEXTFIELD_VIEWS_H_ | 5 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
| 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ | 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 virtual void WriteDragDataForView(View* sender, | 95 virtual void WriteDragDataForView(View* sender, |
| 96 const gfx::Point& press_pt, | 96 const gfx::Point& press_pt, |
| 97 ui::OSExchangeData* data) OVERRIDE; | 97 ui::OSExchangeData* data) OVERRIDE; |
| 98 virtual int GetDragOperationsForView(View* sender, | 98 virtual int GetDragOperationsForView(View* sender, |
| 99 const gfx::Point& p) OVERRIDE; | 99 const gfx::Point& p) OVERRIDE; |
| 100 virtual bool CanStartDragForView(View* sender, | 100 virtual bool CanStartDragForView(View* sender, |
| 101 const gfx::Point& press_pt, | 101 const gfx::Point& press_pt, |
| 102 const gfx::Point& p) OVERRIDE; | 102 const gfx::Point& p) OVERRIDE; |
| 103 | 103 |
| 104 // NativeTextfieldWrapper overrides: | 104 // NativeTextfieldWrapper overrides: |
| 105 virtual string16 GetText() const OVERRIDE; | 105 virtual base::string16 GetText() const OVERRIDE; |
| 106 virtual void UpdateText() OVERRIDE; | 106 virtual void UpdateText() OVERRIDE; |
| 107 virtual void AppendText(const string16& text) OVERRIDE; | 107 virtual void AppendText(const base::string16& text) OVERRIDE; |
| 108 virtual void InsertOrReplaceText(const string16& text) OVERRIDE; | 108 virtual void InsertOrReplaceText(const base::string16& text) OVERRIDE; |
| 109 virtual base::i18n::TextDirection GetTextDirection() const OVERRIDE; | 109 virtual base::i18n::TextDirection GetTextDirection() const OVERRIDE; |
| 110 virtual string16 GetSelectedText() const OVERRIDE; | 110 virtual base::string16 GetSelectedText() const OVERRIDE; |
| 111 virtual void SelectAll(bool reversed) OVERRIDE; | 111 virtual void SelectAll(bool reversed) OVERRIDE; |
| 112 virtual void ClearSelection() OVERRIDE; | 112 virtual void ClearSelection() OVERRIDE; |
| 113 virtual void UpdateBorder() OVERRIDE; | 113 virtual void UpdateBorder() OVERRIDE; |
| 114 virtual void UpdateTextColor() OVERRIDE; | 114 virtual void UpdateTextColor() OVERRIDE; |
| 115 virtual void UpdateBackgroundColor() OVERRIDE; | 115 virtual void UpdateBackgroundColor() OVERRIDE; |
| 116 virtual void UpdateReadOnly() OVERRIDE; | 116 virtual void UpdateReadOnly() OVERRIDE; |
| 117 virtual void UpdateFont() OVERRIDE; | 117 virtual void UpdateFont() OVERRIDE; |
| 118 virtual void UpdateIsObscured() OVERRIDE; | 118 virtual void UpdateIsObscured() OVERRIDE; |
| 119 virtual void UpdateEnabled() OVERRIDE; | 119 virtual void UpdateEnabled() OVERRIDE; |
| 120 virtual gfx::Insets CalculateInsets() OVERRIDE; | 120 virtual gfx::Insets CalculateInsets() OVERRIDE; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 150 virtual bool HasTextBeingDragged() OVERRIDE; | 150 virtual bool HasTextBeingDragged() OVERRIDE; |
| 151 virtual gfx::Point GetContextMenuLocation() OVERRIDE; | 151 virtual gfx::Point GetContextMenuLocation() OVERRIDE; |
| 152 | 152 |
| 153 // ui::SimpleMenuModel::Delegate overrides | 153 // ui::SimpleMenuModel::Delegate overrides |
| 154 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 154 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 155 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 155 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 156 virtual bool GetAcceleratorForCommandId( | 156 virtual bool GetAcceleratorForCommandId( |
| 157 int command_id, | 157 int command_id, |
| 158 ui::Accelerator* accelerator) OVERRIDE; | 158 ui::Accelerator* accelerator) OVERRIDE; |
| 159 virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE; | 159 virtual bool IsItemForCommandIdDynamic(int command_id) const OVERRIDE; |
| 160 virtual string16 GetLabelForCommandId(int command_id) const OVERRIDE; | 160 virtual base::string16 GetLabelForCommandId(int command_id) const OVERRIDE; |
| 161 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | 161 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
| 162 | 162 |
| 163 // class name of internal | 163 // class name of internal |
| 164 static const char kViewClassName[]; | 164 static const char kViewClassName[]; |
| 165 | 165 |
| 166 protected: | 166 protected: |
| 167 // View override. | 167 // View override. |
| 168 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 168 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
| 169 | 169 |
| 170 private: | 170 private: |
| 171 friend class NativeTextfieldViewsTest; | 171 friend class NativeTextfieldViewsTest; |
| 172 friend class TouchSelectionControllerImplTest; | 172 friend class TouchSelectionControllerImplTest; |
| 173 | 173 |
| 174 // Overridden from ui::TextInputClient: | 174 // Overridden from ui::TextInputClient: |
| 175 virtual void SetCompositionText( | 175 virtual void SetCompositionText( |
| 176 const ui::CompositionText& composition) OVERRIDE; | 176 const ui::CompositionText& composition) OVERRIDE; |
| 177 virtual void ConfirmCompositionText() OVERRIDE; | 177 virtual void ConfirmCompositionText() OVERRIDE; |
| 178 virtual void ClearCompositionText() OVERRIDE; | 178 virtual void ClearCompositionText() OVERRIDE; |
| 179 virtual void InsertText(const string16& text) OVERRIDE; | 179 virtual void InsertText(const base::string16& text) OVERRIDE; |
| 180 virtual void InsertChar(char16 ch, int flags) OVERRIDE; | 180 virtual void InsertChar(char16 ch, int flags) OVERRIDE; |
| 181 virtual gfx::NativeWindow GetAttachedWindow() const OVERRIDE; | 181 virtual gfx::NativeWindow GetAttachedWindow() const OVERRIDE; |
| 182 virtual ui::TextInputType GetTextInputType() const OVERRIDE; | 182 virtual ui::TextInputType GetTextInputType() const OVERRIDE; |
| 183 virtual ui::TextInputMode GetTextInputMode() const OVERRIDE; | 183 virtual ui::TextInputMode GetTextInputMode() const OVERRIDE; |
| 184 virtual bool CanComposeInline() const OVERRIDE; | 184 virtual bool CanComposeInline() const OVERRIDE; |
| 185 virtual gfx::Rect GetCaretBounds() const OVERRIDE; | 185 virtual gfx::Rect GetCaretBounds() const OVERRIDE; |
| 186 virtual bool GetCompositionCharacterBounds(uint32 index, | 186 virtual bool GetCompositionCharacterBounds(uint32 index, |
| 187 gfx::Rect* rect) const OVERRIDE; | 187 gfx::Rect* rect) const OVERRIDE; |
| 188 virtual bool HasCompositionText() const OVERRIDE; | 188 virtual bool HasCompositionText() const OVERRIDE; |
| 189 virtual bool GetTextRange(gfx::Range* range) const OVERRIDE; | 189 virtual bool GetTextRange(gfx::Range* range) const OVERRIDE; |
| 190 virtual bool GetCompositionTextRange(gfx::Range* range) const OVERRIDE; | 190 virtual bool GetCompositionTextRange(gfx::Range* range) const OVERRIDE; |
| 191 virtual bool GetSelectionRange(gfx::Range* range) const OVERRIDE; | 191 virtual bool GetSelectionRange(gfx::Range* range) const OVERRIDE; |
| 192 virtual bool SetSelectionRange(const gfx::Range& range) OVERRIDE; | 192 virtual bool SetSelectionRange(const gfx::Range& range) OVERRIDE; |
| 193 virtual bool DeleteRange(const gfx::Range& range) OVERRIDE; | 193 virtual bool DeleteRange(const gfx::Range& range) OVERRIDE; |
| 194 virtual bool GetTextFromRange(const gfx::Range& range, | 194 virtual bool GetTextFromRange(const gfx::Range& range, |
| 195 string16* text) const OVERRIDE; | 195 base::string16* text) const OVERRIDE; |
| 196 virtual void OnInputMethodChanged() OVERRIDE; | 196 virtual void OnInputMethodChanged() OVERRIDE; |
| 197 virtual bool ChangeTextDirectionAndLayoutAlignment( | 197 virtual bool ChangeTextDirectionAndLayoutAlignment( |
| 198 base::i18n::TextDirection direction) OVERRIDE; | 198 base::i18n::TextDirection direction) OVERRIDE; |
| 199 virtual void ExtendSelectionAndDelete(size_t before, size_t after) OVERRIDE; | 199 virtual void ExtendSelectionAndDelete(size_t before, size_t after) OVERRIDE; |
| 200 virtual void EnsureCaretInRect(const gfx::Rect& rect) OVERRIDE; | 200 virtual void EnsureCaretInRect(const gfx::Rect& rect) OVERRIDE; |
| 201 virtual void OnCandidateWindowShown() OVERRIDE; | 201 virtual void OnCandidateWindowShown() OVERRIDE; |
| 202 virtual void OnCandidateWindowUpdated() OVERRIDE; | 202 virtual void OnCandidateWindowUpdated() OVERRIDE; |
| 203 virtual void OnCandidateWindowHidden() OVERRIDE; | 203 virtual void OnCandidateWindowHidden() OVERRIDE; |
| 204 | 204 |
| 205 // Overridden from TextfieldViewsModel::Delegate: | 205 // Overridden from TextfieldViewsModel::Delegate: |
| 206 virtual void OnCompositionTextConfirmedOrCleared() OVERRIDE; | 206 virtual void OnCompositionTextConfirmedOrCleared() OVERRIDE; |
| 207 | 207 |
| 208 // Returns the TextfieldViewsModel's text/cursor/selection rendering model. | 208 // Returns the TextfieldViewsModel's text/cursor/selection rendering model. |
| 209 gfx::RenderText* GetRenderText() const; | 209 gfx::RenderText* GetRenderText() const; |
| 210 | 210 |
| 211 // Converts |text| according to textfield style, e.g. lower case if | 211 // Converts |text| according to textfield style, e.g. lower case if |
| 212 // |textfield_| has STYLE_LOWERCASE style. | 212 // |textfield_| has STYLE_LOWERCASE style. |
| 213 string16 GetTextForDisplay(const string16& text); | 213 base::string16 GetTextForDisplay(const base::string16& text); |
| 214 | 214 |
| 215 // Updates any colors that have not been explicitly set from the theme. | 215 // Updates any colors that have not been explicitly set from the theme. |
| 216 void UpdateColorsFromTheme(const ui::NativeTheme* theme); | 216 void UpdateColorsFromTheme(const ui::NativeTheme* theme); |
| 217 | 217 |
| 218 // A callback function to periodically update the cursor state. | 218 // A callback function to periodically update the cursor state. |
| 219 void UpdateCursor(); | 219 void UpdateCursor(); |
| 220 | 220 |
| 221 // Repaint the cursor. | 221 // Repaint the cursor. |
| 222 void RepaintCursor(); | 222 void RepaintCursor(); |
| 223 | 223 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 // obscured text. When the timer is running, the last typed char is shown | 336 // obscured text. When the timer is running, the last typed char is shown |
| 337 // and when the time expires, the last typed char is obscured. | 337 // and when the time expires, the last typed char is obscured. |
| 338 base::OneShotTimer<NativeTextfieldViews> obscured_reveal_timer_; | 338 base::OneShotTimer<NativeTextfieldViews> obscured_reveal_timer_; |
| 339 | 339 |
| 340 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews); | 340 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews); |
| 341 }; | 341 }; |
| 342 | 342 |
| 343 } // namespace views | 343 } // namespace views |
| 344 | 344 |
| 345 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ | 345 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
| OLD | NEW |