diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-09 23:41:48 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-09 23:41:48 +0000 |
commit | 981e66948a84c10067e9064b6ef482ba5bb277cf (patch) | |
tree | c67dd1a65eee9d5174c4bfdd269f6bdc2acac430 /views | |
parent | e2e88e7f5dbcbb2367d632b534ca0e75aab9f25c (diff) | |
download | chromium_src-981e66948a84c10067e9064b6ef482ba5bb277cf.zip chromium_src-981e66948a84c10067e9064b6ef482ba5bb277cf.tar.gz chromium_src-981e66948a84c10067e9064b6ef482ba5bb277cf.tar.bz2 |
Revert 74377 - Migrate Event API methods to Google Style.
BUG=72040
TEST=none
Review URL: http://codereview.chromium.org/6480001
TBR=ben@chromium.org
Review URL: http://codereview.chromium.org/6469014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74379 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/button/button.cc | 2 | ||||
-rw-r--r-- | views/controls/button/button_dropdown.cc | 2 | ||||
-rw-r--r-- | views/controls/button/custom_button.cc | 8 | ||||
-rw-r--r-- | views/controls/button/menu_button.cc | 20 | ||||
-rw-r--r-- | views/controls/combobox/combobox.cc | 2 | ||||
-rw-r--r-- | views/controls/link.cc | 12 | ||||
-rw-r--r-- | views/controls/menu/menu_controller.cc | 10 | ||||
-rw-r--r-- | views/controls/menu/submenu_view.cc | 6 | ||||
-rw-r--r-- | views/controls/scrollbar/bitmap_scroll_bar.cc | 4 | ||||
-rw-r--r-- | views/controls/scrollbar/native_scroll_bar_gtk.cc | 4 | ||||
-rw-r--r-- | views/controls/scrollbar/native_scroll_bar_win.cc | 4 | ||||
-rw-r--r-- | views/controls/textfield/native_textfield_views.cc | 10 | ||||
-rw-r--r-- | views/controls/textfield/textfield.cc | 2 | ||||
-rw-r--r-- | views/events/event.h | 126 | ||||
-rw-r--r-- | views/focus/focus_manager.cc | 7 | ||||
-rw-r--r-- | views/focus/focus_manager_unittest.cc | 4 | ||||
-rw-r--r-- | views/native_types.h | 28 | ||||
-rw-r--r-- | views/view_unittest.cc | 6 | ||||
-rw-r--r-- | views/widget/root_view.cc | 26 | ||||
-rw-r--r-- | views/widget/widget_gtk.cc | 6 |
20 files changed, 153 insertions, 136 deletions
diff --git a/views/controls/button/button.cc b/views/controls/button/button.cc index 7b6cc75..b59fd89 100644 --- a/views/controls/button/button.cc +++ b/views/controls/button/button.cc @@ -52,7 +52,7 @@ Button::Button(ButtonListener* listener) } void Button::NotifyClick(const views::Event& event) { - mouse_event_flags_ = event.IsMouseEvent() ? event.flags() : 0; + mouse_event_flags_ = event.IsMouseEvent() ? event.GetFlags() : 0; // We can be called when there is no listener, in cases like double clicks on // menu buttons etc. if (listener_) diff --git a/views/controls/button/button_dropdown.cc b/views/controls/button/button_dropdown.cc index 1d7004e..16f424f 100644 --- a/views/controls/button/button_dropdown.cc +++ b/views/controls/button/button_dropdown.cc @@ -124,7 +124,7 @@ bool ButtonDropDown::ShouldEnterPushedState(const MouseEvent& e) { // Enter PUSHED state on press with Left or Right mouse button. Remain // in this state while the context menu is open. return ((MouseEvent::EF_LEFT_BUTTON_DOWN | - MouseEvent::EF_RIGHT_BUTTON_DOWN) & e.flags()) != 0; + MouseEvent::EF_RIGHT_BUTTON_DOWN) & e.GetFlags()) != 0; } void ButtonDropDown::ShowDropDownMenu(gfx::NativeView window) { diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc index af419d4..56abaeb 100644 --- a/views/controls/button/custom_button.cc +++ b/views/controls/button/custom_button.cc @@ -125,7 +125,7 @@ CustomButton::CustomButton(ButtonListener* listener) } bool CustomButton::IsTriggerableEvent(const MouseEvent& e) { - return (triggerable_event_flags_ & e.flags()) != 0; + return (triggerable_event_flags_ & e.GetFlags()) != 0; } //////////////////////////////////////////////////////////////////////////////// @@ -203,9 +203,9 @@ bool CustomButton::OnKeyPressed(const KeyEvent& e) { // Space sets button state to pushed. Enter clicks the button. This matches // the Windows native behavior of buttons, where Space clicks the button on // KeyRelease and Enter clicks the button on KeyPressed. - if (e.key_code() == ui::VKEY_SPACE) { + if (e.GetKeyCode() == ui::VKEY_SPACE) { SetState(BS_PUSHED); - } else if (e.key_code() == ui::VKEY_RETURN) { + } else if (e.GetKeyCode() == ui::VKEY_RETURN) { SetState(BS_NORMAL); NotifyClick(e); } else { @@ -215,7 +215,7 @@ bool CustomButton::OnKeyPressed(const KeyEvent& e) { } bool CustomButton::OnKeyReleased(const KeyEvent& e) { - if ((state_ == BS_DISABLED) || (e.key_code() != ui::VKEY_SPACE)) + if ((state_ == BS_DISABLED) || (e.GetKeyCode() != ui::VKEY_SPACE)) return false; SetState(BS_NORMAL); diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc index 766b3dc..0cd933e 100644 --- a/views/controls/button/menu_button.cc +++ b/views/controls/button/menu_button.cc @@ -220,18 +220,14 @@ void MenuButton::OnMouseReleased(const MouseEvent& e, } bool MenuButton::OnKeyPressed(const KeyEvent& e) { - switch (e.key_code()) { - case ui::VKEY_SPACE: - case ui::VKEY_RETURN: - case ui::VKEY_UP: - case ui::VKEY_DOWN: { - bool result = Activate(); - if (GetFocusManager()->GetFocusedView() == NULL) - RequestFocus(); - return result; - } - default: - break; + if (e.GetKeyCode() == ui::VKEY_SPACE || + e.GetKeyCode() == ui::VKEY_RETURN || + e.GetKeyCode() == ui::VKEY_UP || + e.GetKeyCode() == ui::VKEY_DOWN) { + bool result = Activate(); + if (GetFocusManager()->GetFocusedView() == NULL) + RequestFocus(); + return result; } return false; } diff --git a/views/controls/combobox/combobox.cc b/views/controls/combobox/combobox.cc index 2349bbb..0c7f293 100644 --- a/views/controls/combobox/combobox.cc +++ b/views/controls/combobox/combobox.cc @@ -77,7 +77,7 @@ void Combobox::SetEnabled(bool flag) { // VKEY_ESCAPE should be handled by this view when the drop down list is active. // In other words, the list should be closed instead of the dialog. bool Combobox::SkipDefaultKeyEventProcessing(const KeyEvent& e) { - if (e.key_code() != ui::VKEY_ESCAPE || + if (e.GetKeyCode() != ui::VKEY_ESCAPE || e.IsShiftDown() || e.IsControlDown() || e.IsAltDown()) { return false; } diff --git a/views/controls/link.cc b/views/controls/link.cc index a9affb3..ab48bc2 100644 --- a/views/controls/link.cc +++ b/views/controls/link.cc @@ -121,13 +121,13 @@ void Link::OnMouseReleased(const MouseEvent& e, bool canceled) { RequestFocus(); if (controller_) - controller_->LinkActivated(this, e.flags()); + controller_->LinkActivated(this, e.GetFlags()); } } bool Link::OnKeyPressed(const KeyEvent& e) { - bool activate = ((e.key_code() == ui::VKEY_SPACE) || - (e.key_code() == ui::VKEY_RETURN)); + bool activate = ((e.GetKeyCode() == ui::VKEY_SPACE) || + (e.GetKeyCode() == ui::VKEY_RETURN)); if (!activate) return false; @@ -137,15 +137,15 @@ bool Link::OnKeyPressed(const KeyEvent& e) { RequestFocus(); if (controller_) - controller_->LinkActivated(this, e.flags()); + controller_->LinkActivated(this, e.GetFlags()); return true; } bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& e) { // Make sure we don't process space or enter as accelerators. - return (e.key_code() == ui::VKEY_SPACE) || - (e.key_code() == ui::VKEY_RETURN); + return (e.GetKeyCode() == ui::VKEY_SPACE) || + (e.GetKeyCode() == ui::VKEY_RETURN); } AccessibilityTypes::Role Link::GetAccessibleRole() { diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index 1632b72..660f8ef 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -523,13 +523,13 @@ void MenuController::OnMouseReleased(SubmenuView* source, // contents of the folder. if (!part.is_scroll() && part.menu && !(part.menu->HasSubmenu() && - (event.flags() == MouseEvent::EF_LEFT_BUTTON_DOWN))) { + (event.GetFlags() == MouseEvent::EF_LEFT_BUTTON_DOWN))) { if (active_mouse_view_) { SendMouseReleaseToActiveView(source, event, false); return; } if (part.menu->GetDelegate()->IsTriggerableEvent(event)) { - Accept(part.menu, event.flags()); + Accept(part.menu, event.GetFlags()); return; } } else if (part.type == MenuPart::MENU_ITEM) { @@ -1795,7 +1795,7 @@ void MenuController::UpdateActiveMouseView(SubmenuView* event_source, MouseEvent mouse_pressed_event(MouseEvent::ET_MOUSE_PRESSED, target_point.x(), target_point.y(), - event.flags()); + event.GetFlags()); active_mouse_view_->OnMousePressed(mouse_pressed_event); } } @@ -1805,7 +1805,7 @@ void MenuController::UpdateActiveMouseView(SubmenuView* event_source, View::ConvertPointToView(target_menu, active_mouse_view_, &target_point); MouseEvent mouse_dragged_event(MouseEvent::ET_MOUSE_DRAGGED, target_point.x(), target_point.y(), - event.flags()); + event.GetFlags()); active_mouse_view_->OnMouseDragged(mouse_dragged_event); } } @@ -1821,7 +1821,7 @@ void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source, &target_loc); View::ConvertPointToView(NULL, active_mouse_view_, &target_loc); MouseEvent release_event(Event::ET_MOUSE_RELEASED, target_loc.x(), - target_loc.y(), event.flags()); + target_loc.y(), event.GetFlags()); // Reset the active_mouse_view_ before sending mouse released. That way if if // calls back to use we aren't in a weird state. View* active_view = active_mouse_view_; diff --git a/views/controls/menu/submenu_view.cc b/views/controls/menu/submenu_view.cc index 8a1f079..56bd103 100644 --- a/views/controls/menu/submenu_view.cc +++ b/views/controls/menu/submenu_view.cc @@ -195,11 +195,11 @@ bool SubmenuView::OnMouseWheel(const MouseWheelEvent& e) { // If the first item isn't entirely visible, make it visible, otherwise make // the next/previous one entirely visible. #if defined(OS_WIN) - int delta = abs(e.offset() / WHEEL_DELTA); + int delta = abs(e.GetOffset() / WHEEL_DELTA); #elif defined(OS_LINUX) - int delta = abs(e.offset()); + int delta = abs(e.GetOffset()); #endif - for (bool scroll_up = (e.offset() > 0); delta != 0; --delta) { + for (bool scroll_up = (e.GetOffset() > 0); delta != 0; --delta) { int scroll_target; if (scroll_up) { if (GetMenuItemAt(first_vis_index)->y() == vis_bounds.y()) { diff --git a/views/controls/scrollbar/bitmap_scroll_bar.cc b/views/controls/scrollbar/bitmap_scroll_bar.cc index a60d666..cf0e919 100644 --- a/views/controls/scrollbar/bitmap_scroll_bar.cc +++ b/views/controls/scrollbar/bitmap_scroll_bar.cc @@ -491,13 +491,13 @@ void BitmapScrollBar::OnMouseReleased(const MouseEvent& event, bool canceled) { } bool BitmapScrollBar::OnMouseWheel(const MouseWheelEvent& event) { - ScrollByContentsOffset(event.offset()); + ScrollByContentsOffset(event.GetOffset()); return true; } bool BitmapScrollBar::OnKeyPressed(const KeyEvent& event) { ScrollAmount amount = SCROLL_NONE; - switch (event.key_code()) { + switch (event.GetKeyCode()) { case ui::VKEY_UP: if (!IsHorizontal()) amount = SCROLL_PREV_LINE; diff --git a/views/controls/scrollbar/native_scroll_bar_gtk.cc b/views/controls/scrollbar/native_scroll_bar_gtk.cc index dc1a9b6..73bb109 100644 --- a/views/controls/scrollbar/native_scroll_bar_gtk.cc +++ b/views/controls/scrollbar/native_scroll_bar_gtk.cc @@ -44,7 +44,7 @@ gfx::Size NativeScrollBarGtk::GetPreferredSize() { bool NativeScrollBarGtk::OnKeyPressed(const KeyEvent& event) { if (!native_view()) return false; - switch (event.key_code()) { + switch (event.GetKeyCode()) { case ui::VKEY_UP: if (!native_scroll_bar_->IsHorizontal()) MoveStep(false /* negative */); @@ -82,7 +82,7 @@ bool NativeScrollBarGtk::OnKeyPressed(const KeyEvent& event) { bool NativeScrollBarGtk::OnMouseWheel(const MouseWheelEvent& e) { if (!native_view()) return false; - MoveBy(-e.offset()); // e.GetOffset() > 0 means scroll up. + MoveBy(-e.GetOffset()); // e.GetOffset() > 0 means scroll up. return true; } diff --git a/views/controls/scrollbar/native_scroll_bar_win.cc b/views/controls/scrollbar/native_scroll_bar_win.cc index 01cd5f8..44d8bf6 100644 --- a/views/controls/scrollbar/native_scroll_bar_win.cc +++ b/views/controls/scrollbar/native_scroll_bar_win.cc @@ -230,7 +230,7 @@ bool NativeScrollBarWin::OnKeyPressed(const KeyEvent& event) { if (!sb_container_.get()) return false; int code = -1; - switch (event.key_code()) { + switch (event.GetKeyCode()) { case ui::VKEY_UP: if (!native_scroll_bar_->IsHorizontal()) code = SB_LINEUP; @@ -272,7 +272,7 @@ bool NativeScrollBarWin::OnKeyPressed(const KeyEvent& event) { bool NativeScrollBarWin::OnMouseWheel(const MouseWheelEvent& e) { if (!sb_container_.get()) return false; - sb_container_->ScrollWithOffset(e.offset()); + sb_container_->ScrollWithOffset(e.GetOffset()); return true; } diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc index 3b3e15e..11649ebf 100644 --- a/views/controls/textfield/native_textfield_views.cc +++ b/views/controls/textfield/native_textfield_views.cc @@ -531,8 +531,8 @@ void NativeTextfieldViews::PaintTextAndCursor(gfx::Canvas* canvas) { bool NativeTextfieldViews::HandleKeyEvent(const KeyEvent& key_event) { // TODO(oshima): handle IME. - if (key_event.type() == views::Event::ET_KEY_PRESSED) { - ui::KeyboardCode key_code = key_event.key_code(); + if (key_event.GetType() == views::Event::ET_KEY_PRESSED) { + ui::KeyboardCode key_code = key_event.GetKeyCode(); // TODO(oshima): shift-tab does not work. Figure out why and fix. if (key_code == ui::VKEY_TAB) return false; @@ -642,7 +642,7 @@ bool NativeTextfieldViews::HandleKeyEvent(const KeyEvent& key_event) { char16 NativeTextfieldViews::GetPrintableChar(const KeyEvent& key_event) { // TODO(oshima): IME, i18n support. // This only works for UCS-2 characters. - ui::KeyboardCode key_code = key_event.key_code(); + ui::KeyboardCode key_code = key_event.GetKeyCode(); bool shift = key_event.IsShiftDown(); bool upper = shift ^ key_event.IsCapsLockDown(); // TODO(oshima): We should have a utility function @@ -790,9 +790,9 @@ size_t NativeTextfieldViews::FindCursorPosition(const gfx::Point& point) const { bool NativeTextfieldViews::HandleMousePressed(const views::MouseEvent& e) { textfield_->RequestFocus(); - base::TimeDelta time_delta = e.time_stamp() - last_mouse_press_time_; + base::TimeDelta time_delta = e.GetTimeStamp() - last_mouse_press_time_; gfx::Point location_delta = e.location().Subtract(last_mouse_press_location_); - last_mouse_press_time_ = e.time_stamp(); + last_mouse_press_time_ = e.GetTimeStamp(); last_mouse_press_location_ = e.location(); if (e.IsLeftMouseButton()) { if (!ExceededDragThreshold(location_delta.x(), location_delta.y()) diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc index 9028f88..1b4461c 100644 --- a/views/controls/textfield/textfield.cc +++ b/views/controls/textfield/textfield.cc @@ -309,7 +309,7 @@ void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) { bool Textfield::SkipDefaultKeyEventProcessing(const KeyEvent& e) { // TODO(hamaji): Figure out which keyboard combinations we need to add here, // similar to LocationBarView::SkipDefaultKeyEventProcessing. - ui::KeyboardCode key = e.key_code(); + ui::KeyboardCode key = e.GetKeyCode(); if (key == ui::VKEY_BACK) return true; // We'll handle BackSpace ourselves. diff --git a/views/events/event.h b/views/events/event.h index c641795..b16371e 100644 --- a/views/events/event.h +++ b/views/events/event.h @@ -10,7 +10,6 @@ #include "base/time.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/gfx/point.h" -#include "views/native_types.h" #if defined(OS_LINUX) typedef struct _GdkEventKey GdkEventKey; @@ -77,18 +76,43 @@ class Event { EF_COMMAND_DOWN = 1 << 7, // Only useful on OSX }; - const NativeEvent& native_event() const { return native_event_; } - EventType type() const { return type_; } - const base::Time& time_stamp() const { return time_stamp_; } - int flags() const { return flags_; } - void set_flags(int flags) { flags_ = flags; } + // Return the event type + EventType GetType() const { + return type_; + } + + // Return the event time stamp. + const base::Time& GetTimeStamp() const { + return time_stamp_; + } + + // Return the flags + int GetFlags() const { + return flags_; + } + + void set_flags(int flags) { + flags_ = flags; + } - // The following methods return true if the respective keys were pressed at - // the time the event was created. - bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; } - bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; } - bool IsCapsLockDown() const { return (flags_ & EF_CAPS_LOCK_DOWN) != 0; } - bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; } + // Return whether the shift modifier is down + bool IsShiftDown() const { + return (flags_ & EF_SHIFT_DOWN) != 0; + } + + // Return whether the control modifier is down + bool IsControlDown() const { + return (flags_ & EF_CONTROL_DOWN) != 0; + } + + bool IsCapsLockDown() const { + return (flags_ & EF_CAPS_LOCK_DOWN) != 0; + } + + // Return whether the alt modifier is down + bool IsAltDown() const { + return (flags_ & EF_ALT_DOWN) != 0; + } bool IsMouseEvent() const { return type_ == ET_MOUSE_PRESSED || @@ -125,16 +149,14 @@ class Event { Event(EventType type, int flags); Event(const Event& model) - : native_event_(model.native_event()), - type_(model.type()), - time_stamp_(model.time_stamp()), - flags_(model.flags()) { + : type_(model.GetType()), + time_stamp_(model.GetTimeStamp()), + flags_(model.GetFlags()) { } private: void operator=(const Event&); - NativeEvent native_event_; EventType type_; base::Time time_stamp_; int flags_; @@ -160,9 +182,20 @@ class LocatedEvent : public Event { // from 'from' coordinate system to 'to' coordinate system LocatedEvent(const LocatedEvent& model, View* from, View* to); - int x() const { return location_.x(); } - int y() const { return location_.y(); } - const gfx::Point& location() const { return location_; } + // Returns the X location. + int x() const { + return location_.x(); + } + + // Returns the Y location. + int y() const { + return location_.y(); + } + + // Returns the location. + const gfx::Point& location() const { + return location_; + } private: gfx::Point location_; @@ -209,30 +242,30 @@ class MouseEvent : public LocatedEvent { // Conveniences to quickly test what button is down bool IsOnlyLeftMouseButton() const { - return (flags() & EF_LEFT_BUTTON_DOWN) && - !(flags() & (EF_MIDDLE_BUTTON_DOWN | EF_RIGHT_BUTTON_DOWN)); + return (GetFlags() & EF_LEFT_BUTTON_DOWN) && + !(GetFlags() & (EF_MIDDLE_BUTTON_DOWN | EF_RIGHT_BUTTON_DOWN)); } bool IsLeftMouseButton() const { - return (flags() & EF_LEFT_BUTTON_DOWN) != 0; + return (GetFlags() & EF_LEFT_BUTTON_DOWN) != 0; } bool IsOnlyMiddleMouseButton() const { - return (flags() & EF_MIDDLE_BUTTON_DOWN) && - !(flags() & (EF_LEFT_BUTTON_DOWN | EF_RIGHT_BUTTON_DOWN)); + return (GetFlags() & EF_MIDDLE_BUTTON_DOWN) && + !(GetFlags() & (EF_LEFT_BUTTON_DOWN | EF_RIGHT_BUTTON_DOWN)); } bool IsMiddleMouseButton() const { - return (flags() & EF_MIDDLE_BUTTON_DOWN) != 0; + return (GetFlags() & EF_MIDDLE_BUTTON_DOWN) != 0; } bool IsOnlyRightMouseButton() const { - return (flags() & EF_RIGHT_BUTTON_DOWN) && - !(flags() & (EF_LEFT_BUTTON_DOWN | EF_MIDDLE_BUTTON_DOWN)); + return (GetFlags() & EF_RIGHT_BUTTON_DOWN) && + !(GetFlags() & (EF_LEFT_BUTTON_DOWN | EF_MIDDLE_BUTTON_DOWN)); } bool IsRightMouseButton() const { - return (flags() & EF_RIGHT_BUTTON_DOWN) != 0; + return (GetFlags() & EF_RIGHT_BUTTON_DOWN) != 0; } private: @@ -273,7 +306,10 @@ class TouchEvent : public LocatedEvent { explicit TouchEvent(XEvent* xev); #endif - bool identity() const { return touch_id_; } + // Return the touch point for this event. + bool identity() const { + return touch_id_; + } private: // The identity (typically finger) of the touch starting at 0 and incrementing @@ -319,15 +355,25 @@ class KeyEvent : public Event { explicit KeyEvent(XEvent* xevent); #endif - ui::KeyboardCode key_code() const { return key_code_; } + // This returns a VKEY_ value as defined in app/keyboard_codes.h which is + // the Windows value. + // On GTK, you can use the methods in keyboard_code_conversion_gtk.cc to + // convert this value back to a GDK value if needed. + ui::KeyboardCode GetKeyCode() const { + return key_code_; + } #if defined(OS_WIN) bool IsExtendedKey() const; - UINT message() const { return message_; } + UINT message() const { + return message_; + } #endif - int repeat_count() const { return repeat_count_; } + int GetRepeatCount() const { + return repeat_count_; + } #if defined(OS_WIN) static int GetKeyStateFlags(); @@ -366,7 +412,9 @@ class MouseWheelEvent : public LocatedEvent { explicit MouseWheelEvent(XEvent* xev); #endif - int offset() const { return offset_; } + int GetOffset() const { + return offset_; + } private: int offset_; @@ -393,14 +441,14 @@ class DropTargetEvent : public LocatedEvent { source_operations_(source_operations) { } - const OSExchangeData& data() const { return data_; } - int source_operations() const { return source_operations_; } - - private: // Data associated with the drag/drop session. - const OSExchangeData& data_; + const OSExchangeData& GetData() const { return data_; } // Bitmask of supported ui::DragDropTypes::DragOperation by the source. + int GetSourceOperations() const { return source_operations_; } + + private: + const OSExchangeData& data_; int source_operations_; DISALLOW_COPY_AND_ASSIGN(DropTargetEvent); diff --git a/views/focus/focus_manager.cc b/views/focus/focus_manager.cc index 5e5b2f4..d217e63 100644 --- a/views/focus/focus_manager.cc +++ b/views/focus/focus_manager.cc @@ -120,7 +120,7 @@ bool FocusManager::OnKeyEvent(const KeyEvent& event) { #endif // Intercept arrow key messages to switch between grouped views. - ui::KeyboardCode key_code = event.key_code(); + ui::KeyboardCode key_code = event.GetKeyCode(); if (focused_view_ && focused_view_->GetGroup() != -1 && (key_code == ui::VKEY_UP || key_code == ui::VKEY_DOWN || key_code == ui::VKEY_LEFT || key_code == ui::VKEY_RIGHT)) { @@ -146,7 +146,7 @@ bool FocusManager::OnKeyEvent(const KeyEvent& event) { // Process keyboard accelerators. // If the key combination matches an accelerator, the accelerator is // triggered, otherwise the key event is processed as usual. - Accelerator accelerator(event.key_code(), + Accelerator accelerator(event.GetKeyCode(), event.IsShiftDown(), event.IsControlDown(), event.IsAltDown()); @@ -509,7 +509,8 @@ AcceleratorTarget* FocusManager::GetCurrentTargetForAccelerator( // static bool FocusManager::IsTabTraversalKeyEvent(const KeyEvent& key_event) { - return key_event.key_code() == ui::VKEY_TAB && !key_event.IsControlDown(); + return key_event.GetKeyCode() == ui::VKEY_TAB && + !key_event.IsControlDown(); } void FocusManager::ViewRemoved(View* parent, View* removed) { diff --git a/views/focus/focus_manager_unittest.cc b/views/focus/focus_manager_unittest.cc index 457ed09..bd21c16 100644 --- a/views/focus/focus_manager_unittest.cc +++ b/views/focus/focus_manager_unittest.cc @@ -1448,12 +1448,12 @@ class MessageTrackingView : public View { } virtual bool OnKeyPressed(const KeyEvent& e) { - keys_pressed_.push_back(e.key_code()); + keys_pressed_.push_back(e.GetKeyCode()); return true; } virtual bool OnKeyReleased(const KeyEvent& e) { - keys_released_.push_back(e.key_code()); + keys_released_.push_back(e.GetKeyCode()); return true; } diff --git a/views/native_types.h b/views/native_types.h deleted file mode 100644 index abea52e..0000000 --- a/views/native_types.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef VIEWS_NATIVE_TYPES_H_ -#define VIEWS_NATIVE_TYPES_H_ -#pragma once - -#include "ui/gfx/native_widget_types.h" - -namespace views { - -#if defined(OS_WIN) -typedef MSG NativeEvent; -#endif -#if defined(OS_LINUX) -typedef union _GdkEvent GdkEvent; -typedef GdkEvent* NativeEvent; -#endif -#if defined(TOUCH_UI) -typedef union _XEvent XEvent; -typedef XEvent* NativeEvent; -#endif - -} // namespace views - -#endif // VIEWS_NATIVE_TYPES_H_ - diff --git a/views/view_unittest.cc b/views/view_unittest.cc index 5f4d672..d2dc693 100644 --- a/views/view_unittest.cc +++ b/views/view_unittest.cc @@ -326,19 +326,19 @@ TEST_F(ViewTest, AddRemoveNotifications) { //////////////////////////////////////////////////////////////////////////////// bool TestView::OnMousePressed(const MouseEvent& event) { - last_mouse_event_type_ = event.type(); + last_mouse_event_type_ = event.GetType(); location_.SetPoint(event.x(), event.y()); return true; } bool TestView::OnMouseDragged(const MouseEvent& event) { - last_mouse_event_type_ = event.type(); + last_mouse_event_type_ = event.GetType(); location_.SetPoint(event.x(), event.y()); return true; } void TestView::OnMouseReleased(const MouseEvent& event, bool canceled) { - last_mouse_event_type_ = event.type(); + last_mouse_event_type_ = event.GetType(); location_.SetPoint(event.x(), event.y()); } diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc index 3a24ac8..6010d99 100644 --- a/views/widget/root_view.cc +++ b/views/widget/root_view.cc @@ -386,8 +386,8 @@ bool RootView::OnMousePressed(const MouseEvent& e) { // are formed from a single-click followed by a double-click event. When the // double-click event lands on a different view than its single-click part, // we transform it into a single-click which prevents odd things. - if ((e.flags() & MouseEvent::EF_IS_NON_CLIENT) && - !(e.flags() & MouseEvent::EF_IS_DOUBLE_CLICK)) { + if ((e.GetFlags() & MouseEvent::EF_IS_NON_CLIENT) && + !(e.GetFlags() & MouseEvent::EF_IS_DOUBLE_CLICK)) { last_click_handler_ = NULL; return false; } @@ -424,7 +424,7 @@ bool RootView::OnMousePressed(const MouseEvent& e) { // Remove the double-click flag if the handler is different than the // one which got the first click part of the double-click. if (mouse_pressed_handler_ != last_click_handler_) - mouse_pressed_event.set_flags(e.flags() & + mouse_pressed_event.set_flags(e.GetFlags() & ~MouseEvent::EF_IS_DOUBLE_CLICK); drag_info.Reset(); @@ -469,7 +469,7 @@ bool RootView::OnMousePressed(const MouseEvent& e) { // entire hierarchy (even as a single-click when sent to a different view), // it must be marked as handled to avoid anything happening from default // processing if it the first click-part was handled by us. - if (last_click_handler_ && e.flags() & MouseEvent::EF_IS_DOUBLE_CLICK) + if (last_click_handler_ && e.GetFlags() & MouseEvent::EF_IS_DOUBLE_CLICK) hit_disabled_view = true; last_click_handler_ = NULL; @@ -508,7 +508,7 @@ void RootView::UpdateCursor(const MouseEvent& e) { if (v && v != this) { gfx::Point l(e.location()); View::ConvertPointToView(this, v, &l); - cursor = v->GetCursorForPoint(e.type(), l); + cursor = v->GetCursorForPoint(e.GetType(), l); } SetActiveCursor(cursor); } @@ -521,7 +521,7 @@ bool RootView::OnMouseDragged(const MouseEvent& e) { gfx::Point p; ConvertPointToMouseHandler(e.location(), &p); - MouseEvent mouse_event(e.type(), p.x(), p.y(), e.flags()); + MouseEvent mouse_event(e.GetType(), p.x(), p.y(), e.GetFlags()); return mouse_pressed_handler_->ProcessMouseDragged(mouse_event, &drag_info); } return false; @@ -533,7 +533,7 @@ void RootView::OnMouseReleased(const MouseEvent& e, bool canceled) { if (mouse_pressed_handler_) { gfx::Point p; ConvertPointToMouseHandler(e.location(), &p); - MouseEvent mouse_released(e.type(), p.x(), p.y(), e.flags()); + MouseEvent mouse_released(e.GetType(), p.x(), p.y(), e.GetFlags()); // We allow the view to delete us from ProcessMouseReleased. As such, // configure state such that we're done first, then call View. View* mouse_pressed_handler = mouse_pressed_handler_; @@ -576,7 +576,7 @@ void RootView::OnMouseMoved(const MouseEvent& e) { mouse_move_handler_->OnMouseMoved(moved_event); gfx::NativeCursor cursor = mouse_move_handler_->GetCursorForPoint( - moved_event.type(), moved_event.location()); + moved_event.GetType(), moved_event.location()); SetActiveCursor(cursor); } else if (mouse_move_handler_ != NULL) { MouseEvent exited_event(Event::ET_MOUSE_EXITED, 0, 0, 0); @@ -680,18 +680,18 @@ bool RootView::ProcessKeyEvent(const KeyEvent& event) { View* v = GetFocusedView(); // Special case to handle right-click context menus triggered by the // keyboard. - if (v && v->IsEnabled() && ((event.key_code() == ui::VKEY_APPS) || - (event.key_code() == ui::VKEY_F10 && event.IsShiftDown()))) { + if (v && v->IsEnabled() && ((event.GetKeyCode() == ui::VKEY_APPS) || + (event.GetKeyCode() == ui::VKEY_F10 && event.IsShiftDown()))) { v->ShowContextMenu(v->GetKeyboardContextMenuLocation(), false); return true; } for (; v && v != this && !consumed; v = v->parent()) { - consumed = (event.type() == Event::ET_KEY_PRESSED) ? + consumed = (event.GetType() == Event::ET_KEY_PRESSED) ? v->OnKeyPressed(event) : v->OnKeyReleased(event); } if (!consumed && default_keyboard_handler_) { - consumed = (event.type() == Event::ET_KEY_PRESSED) ? + consumed = (event.GetType() == Event::ET_KEY_PRESSED) ? default_keyboard_handler_->OnKeyPressed(event) : default_keyboard_handler_->OnKeyReleased(event); } @@ -758,7 +758,7 @@ void RootView::UnregisterViewForVisibleBoundsNotification(View* view) { } void RootView::SetMouseLocationAndFlags(const MouseEvent& e) { - last_mouse_event_flags_ = e.flags(); + last_mouse_event_flags_ = e.GetFlags(); last_mouse_event_x_ = e.x(); last_mouse_event_y_ = e.y(); } diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index 4c4466c..730d6f7 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -883,7 +883,7 @@ bool WidgetGtk::HandleKeyboardEvent(GdkEventKey* event) { return false; KeyEvent key(event); - int key_code = key.key_code(); + int key_code = key.GetKeyCode(); bool handled = false; // Always reset |should_handle_menu_key_release_| unless we are handling a @@ -901,7 +901,7 @@ bool WidgetGtk::HandleKeyboardEvent(GdkEventKey* event) { else should_handle_menu_key_release_ = true; } else if (key_code == ui::VKEY_MENU && should_handle_menu_key_release_ && - (key.flags() & ~Event::EF_ALT_DOWN) == 0) { + (key.GetFlags() & ~Event::EF_ALT_DOWN) == 0) { // Trigger VKEY_MENU when only this key is pressed and released, and both // press and release events are not handled by others. Accelerator accelerator(ui::VKEY_MENU, false, false, false); @@ -1174,7 +1174,7 @@ gboolean WidgetGtk::OnKeyEvent(GtkWidget* widget, GdkEventKey* event) { // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only // be activated when handling a VKEY_MENU key release event which is preceded // by an unhandled VKEY_MENU key press event. See also HandleKeyboardEvent(). - if (key.key_code() != ui::VKEY_MENU || event->type != GDK_KEY_RELEASE) + if (key.GetKeyCode() != ui::VKEY_MENU || event->type != GDK_KEY_RELEASE) should_handle_menu_key_release_ = false; bool handled = false; |