| OLD | NEW |
| 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" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // The textfield's class name. | 45 // The textfield's class name. |
| 46 static const char kViewClassName[]; | 46 static const char kViewClassName[]; |
| 47 | 47 |
| 48 // The preferred size of the padding to be used around textfield text. | 48 // The preferred size of the padding to be used around textfield text. |
| 49 static const int kTextPadding; | 49 static const int kTextPadding; |
| 50 | 50 |
| 51 // Returns the text cursor blink time in milliseconds, or 0 for no blinking. | 51 // Returns the text cursor blink time in milliseconds, or 0 for no blinking. |
| 52 static size_t GetCaretBlinkMs(); | 52 static size_t GetCaretBlinkMs(); |
| 53 | 53 |
| 54 Textfield(); | 54 Textfield(); |
| 55 virtual ~Textfield(); | 55 ~Textfield() override; |
| 56 | 56 |
| 57 // Set the controller for this textfield. | 57 // Set the controller for this textfield. |
| 58 void set_controller(TextfieldController* controller) { | 58 void set_controller(TextfieldController* controller) { |
| 59 controller_ = controller; | 59 controller_ = controller; |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Gets/Sets whether or not the Textfield is read-only. | 62 // Gets/Sets whether or not the Textfield is read-only. |
| 63 bool read_only() const { return read_only_; } | 63 bool read_only() const { return read_only_; } |
| 64 void SetReadOnly(bool read_only); | 64 void SetReadOnly(bool read_only); |
| 65 | 65 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 198 |
| 199 // Performs the action associated with the specified command id. | 199 // Performs the action associated with the specified command id. |
| 200 void ExecuteCommand(int command_id); | 200 void ExecuteCommand(int command_id); |
| 201 | 201 |
| 202 void SetFocusPainter(scoped_ptr<Painter> focus_painter); | 202 void SetFocusPainter(scoped_ptr<Painter> focus_painter); |
| 203 | 203 |
| 204 // Returns whether there is a drag operation originating from the textfield. | 204 // Returns whether there is a drag operation originating from the textfield. |
| 205 bool HasTextBeingDragged(); | 205 bool HasTextBeingDragged(); |
| 206 | 206 |
| 207 // View overrides: | 207 // View overrides: |
| 208 virtual gfx::Insets GetInsets() const override; | 208 gfx::Insets GetInsets() const override; |
| 209 virtual int GetBaseline() const override; | 209 int GetBaseline() const override; |
| 210 virtual gfx::Size GetPreferredSize() const override; | 210 gfx::Size GetPreferredSize() const override; |
| 211 virtual const char* GetClassName() const override; | 211 const char* GetClassName() const override; |
| 212 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override; | 212 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override; |
| 213 virtual bool OnMousePressed(const ui::MouseEvent& event) override; | 213 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 214 virtual bool OnMouseDragged(const ui::MouseEvent& event) override; | 214 bool OnMouseDragged(const ui::MouseEvent& event) override; |
| 215 virtual void OnMouseReleased(const ui::MouseEvent& event) override; | 215 void OnMouseReleased(const ui::MouseEvent& event) override; |
| 216 virtual bool OnKeyPressed(const ui::KeyEvent& event) override; | 216 bool OnKeyPressed(const ui::KeyEvent& event) override; |
| 217 virtual ui::TextInputClient* GetTextInputClient() override; | 217 ui::TextInputClient* GetTextInputClient() override; |
| 218 virtual void OnGestureEvent(ui::GestureEvent* event) override; | 218 void OnGestureEvent(ui::GestureEvent* event) override; |
| 219 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) override; | 219 void AboutToRequestFocusFromTabTraversal(bool reverse) override; |
| 220 virtual bool SkipDefaultKeyEventProcessing( | 220 bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) override; |
| 221 const ui::KeyEvent& event) override; | 221 bool GetDropFormats( |
| 222 virtual bool GetDropFormats( | |
| 223 int* formats, | 222 int* formats, |
| 224 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) override; | 223 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) override; |
| 225 virtual bool CanDrop(const ui::OSExchangeData& data) override; | 224 bool CanDrop(const ui::OSExchangeData& data) override; |
| 226 virtual int OnDragUpdated(const ui::DropTargetEvent& event) override; | 225 int OnDragUpdated(const ui::DropTargetEvent& event) override; |
| 227 virtual void OnDragExited() override; | 226 void OnDragExited() override; |
| 228 virtual int OnPerformDrop(const ui::DropTargetEvent& event) override; | 227 int OnPerformDrop(const ui::DropTargetEvent& event) override; |
| 229 virtual void OnDragDone() override; | 228 void OnDragDone() override; |
| 230 virtual void GetAccessibleState(ui::AXViewState* state) override; | 229 void GetAccessibleState(ui::AXViewState* state) override; |
| 231 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | 230 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
| 232 virtual bool GetNeedsNotificationWhenVisibleBoundsChange() const override; | 231 bool GetNeedsNotificationWhenVisibleBoundsChange() const override; |
| 233 virtual void OnVisibleBoundsChanged() override; | 232 void OnVisibleBoundsChanged() override; |
| 234 virtual void OnEnabledChanged() override; | 233 void OnEnabledChanged() override; |
| 235 virtual void OnPaint(gfx::Canvas* canvas) override; | 234 void OnPaint(gfx::Canvas* canvas) override; |
| 236 virtual void OnFocus() override; | 235 void OnFocus() override; |
| 237 virtual void OnBlur() override; | 236 void OnBlur() override; |
| 238 virtual gfx::Point GetKeyboardContextMenuLocation() override; | 237 gfx::Point GetKeyboardContextMenuLocation() override; |
| 239 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 238 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
| 240 | 239 |
| 241 // TextfieldModel::Delegate overrides: | 240 // TextfieldModel::Delegate overrides: |
| 242 virtual void OnCompositionTextConfirmedOrCleared() override; | 241 void OnCompositionTextConfirmedOrCleared() override; |
| 243 | 242 |
| 244 // ContextMenuController overrides: | 243 // ContextMenuController overrides: |
| 245 virtual void ShowContextMenuForView(View* source, | 244 void ShowContextMenuForView(View* source, |
| 246 const gfx::Point& point, | 245 const gfx::Point& point, |
| 247 ui::MenuSourceType source_type) override; | 246 ui::MenuSourceType source_type) override; |
| 248 | 247 |
| 249 // DragController overrides: | 248 // DragController overrides: |
| 250 virtual void WriteDragDataForView(View* sender, | 249 void WriteDragDataForView(View* sender, |
| 251 const gfx::Point& press_pt, | 250 const gfx::Point& press_pt, |
| 252 ui::OSExchangeData* data) override; | 251 ui::OSExchangeData* data) override; |
| 253 virtual int GetDragOperationsForView(View* sender, | 252 int GetDragOperationsForView(View* sender, const gfx::Point& p) override; |
| 254 const gfx::Point& p) override; | 253 bool CanStartDragForView(View* sender, |
| 255 virtual bool CanStartDragForView(View* sender, | 254 const gfx::Point& press_pt, |
| 256 const gfx::Point& press_pt, | 255 const gfx::Point& p) override; |
| 257 const gfx::Point& p) override; | |
| 258 | 256 |
| 259 // ui::TouchEditable overrides: | 257 // ui::TouchEditable overrides: |
| 260 virtual void SelectRect(const gfx::Point& start, | 258 void SelectRect(const gfx::Point& start, const gfx::Point& end) override; |
| 261 const gfx::Point& end) override; | 259 void MoveCaretTo(const gfx::Point& point) override; |
| 262 virtual void MoveCaretTo(const gfx::Point& point) override; | 260 void GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) override; |
| 263 virtual void GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) override; | 261 gfx::Rect GetBounds() override; |
| 264 virtual gfx::Rect GetBounds() override; | 262 gfx::NativeView GetNativeView() const override; |
| 265 virtual gfx::NativeView GetNativeView() const override; | 263 void ConvertPointToScreen(gfx::Point* point) override; |
| 266 virtual void ConvertPointToScreen(gfx::Point* point) override; | 264 void ConvertPointFromScreen(gfx::Point* point) override; |
| 267 virtual void ConvertPointFromScreen(gfx::Point* point) override; | 265 bool DrawsHandles() override; |
| 268 virtual bool DrawsHandles() override; | 266 void OpenContextMenu(const gfx::Point& anchor) override; |
| 269 virtual void OpenContextMenu(const gfx::Point& anchor) override; | 267 void DestroyTouchSelection() override; |
| 270 virtual void DestroyTouchSelection() override; | |
| 271 | 268 |
| 272 // ui::SimpleMenuModel::Delegate overrides: | 269 // ui::SimpleMenuModel::Delegate overrides: |
| 273 virtual bool IsCommandIdChecked(int command_id) const override; | 270 bool IsCommandIdChecked(int command_id) const override; |
| 274 virtual bool IsCommandIdEnabled(int command_id) const override; | 271 bool IsCommandIdEnabled(int command_id) const override; |
| 275 virtual bool GetAcceleratorForCommandId( | 272 bool GetAcceleratorForCommandId(int command_id, |
| 276 int command_id, | 273 ui::Accelerator* accelerator) override; |
| 277 ui::Accelerator* accelerator) override; | 274 void ExecuteCommand(int command_id, int event_flags) override; |
| 278 virtual void ExecuteCommand(int command_id, int event_flags) override; | |
| 279 | 275 |
| 280 // ui::TextInputClient overrides: | 276 // ui::TextInputClient overrides: |
| 281 virtual void SetCompositionText( | 277 void SetCompositionText(const ui::CompositionText& composition) override; |
| 282 const ui::CompositionText& composition) override; | 278 void ConfirmCompositionText() override; |
| 283 virtual void ConfirmCompositionText() override; | 279 void ClearCompositionText() override; |
| 284 virtual void ClearCompositionText() override; | 280 void InsertText(const base::string16& text) override; |
| 285 virtual void InsertText(const base::string16& text) override; | 281 void InsertChar(base::char16 ch, int flags) override; |
| 286 virtual void InsertChar(base::char16 ch, int flags) override; | 282 gfx::NativeWindow GetAttachedWindow() const override; |
| 287 virtual gfx::NativeWindow GetAttachedWindow() const override; | 283 ui::TextInputType GetTextInputType() const override; |
| 288 virtual ui::TextInputType GetTextInputType() const override; | 284 ui::TextInputMode GetTextInputMode() const override; |
| 289 virtual ui::TextInputMode GetTextInputMode() const override; | 285 int GetTextInputFlags() const override; |
| 290 virtual int GetTextInputFlags() const override; | 286 bool CanComposeInline() const override; |
| 291 virtual bool CanComposeInline() const override; | 287 gfx::Rect GetCaretBounds() const override; |
| 292 virtual gfx::Rect GetCaretBounds() const override; | 288 bool GetCompositionCharacterBounds(uint32 index, |
| 293 virtual bool GetCompositionCharacterBounds(uint32 index, | 289 gfx::Rect* rect) const override; |
| 294 gfx::Rect* rect) const override; | 290 bool HasCompositionText() const override; |
| 295 virtual bool HasCompositionText() const override; | 291 bool GetTextRange(gfx::Range* range) const override; |
| 296 virtual bool GetTextRange(gfx::Range* range) const override; | 292 bool GetCompositionTextRange(gfx::Range* range) const override; |
| 297 virtual bool GetCompositionTextRange(gfx::Range* range) const override; | 293 bool GetSelectionRange(gfx::Range* range) const override; |
| 298 virtual bool GetSelectionRange(gfx::Range* range) const override; | 294 bool SetSelectionRange(const gfx::Range& range) override; |
| 299 virtual bool SetSelectionRange(const gfx::Range& range) override; | 295 bool DeleteRange(const gfx::Range& range) override; |
| 300 virtual bool DeleteRange(const gfx::Range& range) override; | 296 bool GetTextFromRange(const gfx::Range& range, |
| 301 virtual bool GetTextFromRange(const gfx::Range& range, | 297 base::string16* text) const override; |
| 302 base::string16* text) const override; | 298 void OnInputMethodChanged() override; |
| 303 virtual void OnInputMethodChanged() override; | 299 bool ChangeTextDirectionAndLayoutAlignment( |
| 304 virtual bool ChangeTextDirectionAndLayoutAlignment( | |
| 305 base::i18n::TextDirection direction) override; | 300 base::i18n::TextDirection direction) override; |
| 306 virtual void ExtendSelectionAndDelete(size_t before, size_t after) override; | 301 void ExtendSelectionAndDelete(size_t before, size_t after) override; |
| 307 virtual void EnsureCaretInRect(const gfx::Rect& rect) override; | 302 void EnsureCaretInRect(const gfx::Rect& rect) override; |
| 308 virtual void OnCandidateWindowShown() override; | 303 void OnCandidateWindowShown() override; |
| 309 virtual void OnCandidateWindowUpdated() override; | 304 void OnCandidateWindowUpdated() override; |
| 310 virtual void OnCandidateWindowHidden() override; | 305 void OnCandidateWindowHidden() override; |
| 311 virtual bool IsEditingCommandEnabled(int command_id) override; | 306 bool IsEditingCommandEnabled(int command_id) override; |
| 312 virtual void ExecuteEditingCommand(int command_id) override; | 307 void ExecuteEditingCommand(int command_id) override; |
| 313 | 308 |
| 314 protected: | 309 protected: |
| 315 // Returns the TextfieldModel's text/cursor/selection rendering model. | 310 // Returns the TextfieldModel's text/cursor/selection rendering model. |
| 316 gfx::RenderText* GetRenderText() const; | 311 gfx::RenderText* GetRenderText() const; |
| 317 | 312 |
| 318 gfx::Point last_click_location() const { return last_click_location_; } | 313 gfx::Point last_click_location() const { return last_click_location_; } |
| 319 | 314 |
| 320 // Get the text from the selection clipboard. | 315 // Get the text from the selection clipboard. |
| 321 virtual base::string16 GetSelectionClipboardText() const; | 316 virtual base::string16 GetSelectionClipboardText() const; |
| 322 | 317 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 470 |
| 476 // Used to bind callback functions to this object. | 471 // Used to bind callback functions to this object. |
| 477 base::WeakPtrFactory<Textfield> weak_ptr_factory_; | 472 base::WeakPtrFactory<Textfield> weak_ptr_factory_; |
| 478 | 473 |
| 479 DISALLOW_COPY_AND_ASSIGN(Textfield); | 474 DISALLOW_COPY_AND_ASSIGN(Textfield); |
| 480 }; | 475 }; |
| 481 | 476 |
| 482 } // namespace views | 477 } // namespace views |
| 483 | 478 |
| 484 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 479 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| OLD | NEW |