From 3446c069d6670e68bf688aac606f4c2c818f22c3 Mon Sep 17 00:00:00 2001 From: "msw@chromium.org" Date: Tue, 3 May 2011 21:48:00 +0000 Subject: Rename View::GetCursor and simplify arguments. Simplify RootView::UpdateCursor with MouseEvent ctor support. Restore pre-r83123 WigetWin::SetCursor(NULL) behavior. Cleanup (function ordering, OVERRIDEs, unnecessary "views::"). This originates from changes and comments of Patch Set 3 at: http://codereview.chromium.org/6893096/ BUG=72040 TEST=Mouse cursors. Review URL: http://codereview.chromium.org/6910032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83970 0039d316-1c4b-4281-b951-d872f2087c98 --- views/controls/textfield/native_textfield_views.cc | 20 ++++++++--------- views/controls/textfield/native_textfield_views.h | 25 +++++++++++----------- 2 files changed, 21 insertions(+), 24 deletions(-) (limited to 'views/controls/textfield') diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc index 546b188..77b8098 100644 --- a/views/controls/textfield/native_textfield_views.cc +++ b/views/controls/textfield/native_textfield_views.cc @@ -86,7 +86,7 @@ NativeTextfieldViews::~NativeTextfieldViews() { //////////////////////////////////////////////////////////////////////////////// // NativeTextfieldViews, View overrides: -bool NativeTextfieldViews::OnMousePressed(const views::MouseEvent& event) { +bool NativeTextfieldViews::OnMousePressed(const MouseEvent& event) { OnBeforeUserAction(); if (HandleMousePressed(event)) SchedulePaint(); @@ -94,7 +94,7 @@ bool NativeTextfieldViews::OnMousePressed(const views::MouseEvent& event) { return true; } -bool NativeTextfieldViews::OnMouseDragged(const views::MouseEvent& event) { +bool NativeTextfieldViews::OnMouseDragged(const MouseEvent& event) { OnBeforeUserAction(); size_t pos = FindCursorPosition(event.location()); if (model_->MoveCursorTo(pos, true)) { @@ -105,14 +105,14 @@ bool NativeTextfieldViews::OnMouseDragged(const views::MouseEvent& event) { return true; } -bool NativeTextfieldViews::OnKeyPressed(const views::KeyEvent& event) { +bool NativeTextfieldViews::OnKeyPressed(const KeyEvent& event) { // OnKeyPressed/OnKeyReleased/OnFocus/OnBlur will never be invoked on // NativeTextfieldViews as it will never gain focus. NOTREACHED(); return false; } -bool NativeTextfieldViews::OnKeyReleased(const views::KeyEvent& event) { +bool NativeTextfieldViews::OnKeyReleased(const KeyEvent& event) { NOTREACHED(); return false; } @@ -133,9 +133,7 @@ void NativeTextfieldViews::OnBlur() { NOTREACHED(); } -gfx::NativeCursor NativeTextfieldViews::GetCursorForPoint( - ui::EventType event_type, - const gfx::Point& p) { +gfx::NativeCursor NativeTextfieldViews::GetCursor(const MouseEvent& event) { #if defined(OS_WIN) static HCURSOR ibeam = LoadCursor(NULL, IDC_IBEAM); return ibeam; @@ -145,7 +143,7 @@ gfx::NativeCursor NativeTextfieldViews::GetCursorForPoint( } ///////////////////////////////////////////////////////////////// -// NativeTextfieldViews, views::ContextMenuController overrides: +// NativeTextfieldViews, ContextMenuController overrides: void NativeTextfieldViews::ShowContextMenuForView(View* source, const gfx::Point& p, bool is_mouse_gesture) { @@ -287,7 +285,7 @@ size_t NativeTextfieldViews::GetCursorPosition() const { return model_->cursor_pos(); } -bool NativeTextfieldViews::HandleKeyPressed(const views::KeyEvent& e) { +bool NativeTextfieldViews::HandleKeyPressed(const KeyEvent& e) { TextfieldController* controller = textfield_->GetController(); bool handled = false; if (controller) @@ -295,7 +293,7 @@ bool NativeTextfieldViews::HandleKeyPressed(const views::KeyEvent& e) { return handled || HandleKeyEvent(e); } -bool NativeTextfieldViews::HandleKeyReleased(const views::KeyEvent& e) { +bool NativeTextfieldViews::HandleKeyReleased(const KeyEvent& e) { return true; } @@ -339,7 +337,7 @@ bool NativeTextfieldViews::IsCommandIdEnabled(int command_id) const { case IDS_APP_COPY: return model_->HasSelection(); case IDS_APP_PASTE: - views::ViewsDelegate::views_delegate->GetClipboard() + ViewsDelegate::views_delegate->GetClipboard() ->ReadText(ui::Clipboard::BUFFER_STANDARD, &result); return editable && !result.empty(); case IDS_APP_DELETE: diff --git a/views/controls/textfield/native_textfield_views.h b/views/controls/textfield/native_textfield_views.h index 69385049c..e95c1a5 100644 --- a/views/controls/textfield/native_textfield_views.h +++ b/views/controls/textfield/native_textfield_views.h @@ -40,8 +40,8 @@ class Menu2; // chromeos, so we may not need them) // * Double click to select word, and triple click to select all. // * Undo/Redo -class NativeTextfieldViews : public views::View, - public views::ContextMenuController, +class NativeTextfieldViews : public View, + public ContextMenuController, public NativeTextfieldWrapper, public ui::SimpleMenuModel::Delegate, public TextInputClient, @@ -50,18 +50,17 @@ class NativeTextfieldViews : public views::View, explicit NativeTextfieldViews(Textfield* parent); ~NativeTextfieldViews(); - // views::View overrides: - virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; - virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; - virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE; - virtual bool OnKeyReleased(const views::KeyEvent& event) OVERRIDE; + // View overrides: + virtual gfx::NativeCursor GetCursor(const MouseEvent& event) OVERRIDE; + virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; + virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; + virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE; + virtual bool OnKeyReleased(const KeyEvent& event) OVERRIDE; virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; virtual void OnFocus() OVERRIDE; virtual void OnBlur() OVERRIDE; - virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type, - const gfx::Point& p) OVERRIDE; - // views::ContextMenuController overrides: + // ContextMenuController overrides: virtual void ShowContextMenuForView(View* source, const gfx::Point& p, bool is_mouse_gesture) OVERRIDE; @@ -90,8 +89,8 @@ class NativeTextfieldViews : public views::View, virtual void GetSelectedRange(ui::Range* range) const OVERRIDE; virtual void SelectRange(const ui::Range& range) OVERRIDE; virtual size_t GetCursorPosition() const OVERRIDE; - virtual bool HandleKeyPressed(const views::KeyEvent& e) OVERRIDE; - virtual bool HandleKeyReleased(const views::KeyEvent& e) OVERRIDE; + virtual bool HandleKeyPressed(const KeyEvent& e) OVERRIDE; + virtual bool HandleKeyReleased(const KeyEvent& e) OVERRIDE; virtual void HandleFocus() OVERRIDE; virtual void HandleBlur() OVERRIDE; virtual TextInputClient* GetTextInputClient() OVERRIDE; @@ -178,7 +177,7 @@ class NativeTextfieldViews : public views::View, size_t FindCursorPosition(const gfx::Point& point) const; // Mouse event handler. Returns true if textfield needs to be repainted. - bool HandleMousePressed(const views::MouseEvent& e); + bool HandleMousePressed(const MouseEvent& e); // Helper function that sets the cursor position at the location of mouse // event. -- cgit v1.1