summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-10 04:56:36 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-10 04:56:36 +0000
commit8d577a70f6e6d2e47f0ac32f8606e489a7a77998 (patch)
tree48eae3f525e0323362db629efa2589e70a5a4e49 /views
parent8fb0ecf45b286845fd2004a157a294d7e3ca7a39 (diff)
downloadchromium_src-8d577a70f6e6d2e47f0ac32f8606e489a7a77998.zip
chromium_src-8d577a70f6e6d2e47f0ac32f8606e489a7a77998.tar.gz
chromium_src-8d577a70f6e6d2e47f0ac32f8606e489a7a77998.tar.bz2
Migrate Event API methods to Google Style.
Re-landing, moving the bits Mac uses to ui/base/events.h BUG=72040 TEST=none TBR=sky Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=74377 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74408 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/accelerator.h12
-rw-r--r--views/controls/button/button.cc2
-rw-r--r--views/controls/button/button_dropdown.cc4
-rw-r--r--views/controls/button/custom_button.cc12
-rw-r--r--views/controls/button/menu_button.cc20
-rw-r--r--views/controls/button/native_button.cc8
-rw-r--r--views/controls/combobox/combobox.cc2
-rw-r--r--views/controls/link.cc14
-rw-r--r--views/controls/link.h2
-rw-r--r--views/controls/menu/menu_controller.cc22
-rw-r--r--views/controls/menu/submenu_view.cc6
-rw-r--r--views/controls/resize_area.cc2
-rw-r--r--views/controls/resize_area.h2
-rw-r--r--views/controls/scrollbar/bitmap_scroll_bar.cc8
-rw-r--r--views/controls/scrollbar/native_scroll_bar_gtk.cc4
-rw-r--r--views/controls/scrollbar/native_scroll_bar_win.cc4
-rw-r--r--views/controls/single_split_view.cc2
-rw-r--r--views/controls/single_split_view.h2
-rw-r--r--views/controls/single_split_view_unittest.cc8
-rw-r--r--views/controls/textfield/native_textfield_views.cc12
-rw-r--r--views/controls/textfield/native_textfield_views.h2
-rw-r--r--views/controls/textfield/native_textfield_views_unittest.cc10
-rw-r--r--views/controls/textfield/native_textfield_win.cc8
-rw-r--r--views/controls/textfield/textfield.cc2
-rw-r--r--views/events/event.cc10
-rw-r--r--views/events/event.h215
-rw-r--r--views/events/event_gtk.cc16
-rw-r--r--views/events/event_win.cc30
-rw-r--r--views/events/event_x.cc54
-rw-r--r--views/focus/accelerator_handler_touch.cc14
-rw-r--r--views/focus/accelerator_handler_win.cc2
-rw-r--r--views/focus/focus_manager.cc7
-rw-r--r--views/focus/focus_manager_unittest.cc4
-rw-r--r--views/native_types.h28
-rw-r--r--views/touchui/gesture_manager.cc12
-rw-r--r--views/view.cc2
-rw-r--r--views/view.h2
-rw-r--r--views/view_unittest.cc44
-rw-r--r--views/widget/root_view.cc40
-rw-r--r--views/widget/widget_gtk.cc30
-rw-r--r--views/widget/widget_win.cc16
-rw-r--r--views/window/window_gtk.cc2
42 files changed, 321 insertions, 377 deletions
diff --git a/views/accelerator.h b/views/accelerator.h
index b399efc..a6cbaf4 100644
--- a/views/accelerator.h
+++ b/views/accelerator.h
@@ -32,25 +32,25 @@ class Accelerator : public ui::Accelerator {
key_code_ = keycode;
modifiers_ = 0;
if (shift_pressed)
- modifiers_ |= Event::EF_SHIFT_DOWN;
+ modifiers_ |= ui::EF_SHIFT_DOWN;
if (ctrl_pressed)
- modifiers_ |= Event::EF_CONTROL_DOWN;
+ modifiers_ |= ui::EF_CONTROL_DOWN;
if (alt_pressed)
- modifiers_ |= Event::EF_ALT_DOWN;
+ modifiers_ |= ui::EF_ALT_DOWN;
}
virtual ~Accelerator() {}
bool IsShiftDown() const {
- return (modifiers_ & Event::EF_SHIFT_DOWN) == Event::EF_SHIFT_DOWN;
+ return (modifiers_ & ui::EF_SHIFT_DOWN) == ui::EF_SHIFT_DOWN;
}
bool IsCtrlDown() const {
- return (modifiers_ & Event::EF_CONTROL_DOWN) == Event::EF_CONTROL_DOWN;
+ return (modifiers_ & ui::EF_CONTROL_DOWN) == ui::EF_CONTROL_DOWN;
}
bool IsAltDown() const {
- return (modifiers_ & Event::EF_ALT_DOWN) == Event::EF_ALT_DOWN;
+ return (modifiers_ & ui::EF_ALT_DOWN) == ui::EF_ALT_DOWN;
}
// Returns a string with the localized shortcut if any.
diff --git a/views/controls/button/button.cc b/views/controls/button/button.cc
index b59fd89..7b6cc75 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.GetFlags() : 0;
+ mouse_event_flags_ = event.IsMouseEvent() ? event.flags() : 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 16f424f..d2f69e2 100644
--- a/views/controls/button/button_dropdown.cc
+++ b/views/controls/button/button_dropdown.cc
@@ -123,8 +123,8 @@ void ButtonDropDown::ShowContextMenu(const gfx::Point& p,
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.GetFlags()) != 0;
+ return ((ui::EF_LEFT_BUTTON_DOWN |
+ ui::EF_RIGHT_BUTTON_DOWN) & e.flags()) != 0;
}
void ButtonDropDown::ShowDropDownMenu(gfx::NativeView window) {
diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc
index 56abaeb..cf2f752 100644
--- a/views/controls/button/custom_button.cc
+++ b/views/controls/button/custom_button.cc
@@ -118,14 +118,14 @@ CustomButton::CustomButton(ButtonListener* listener)
state_(BS_NORMAL),
animate_on_state_change_(true),
is_throbbing_(false),
- triggerable_event_flags_(MouseEvent::EF_LEFT_BUTTON_DOWN),
+ triggerable_event_flags_(ui::EF_LEFT_BUTTON_DOWN),
request_focus_on_press_(true) {
hover_animation_.reset(new ui::ThrobAnimation(this));
hover_animation_->SetSlideDuration(kHoverFadeDurationMs);
}
bool CustomButton::IsTriggerableEvent(const MouseEvent& e) {
- return (triggerable_event_flags_ & e.GetFlags()) != 0;
+ return (triggerable_event_flags_ & e.flags()) != 0;
}
////////////////////////////////////////////////////////////////////////////////
@@ -136,7 +136,7 @@ bool CustomButton::AcceleratorPressed(const Accelerator& accelerator) {
return false;
SetState(BS_NORMAL);
- KeyEvent key_event(Event::ET_KEY_RELEASED, accelerator.GetKeyCode(),
+ KeyEvent key_event(ui::ET_KEY_RELEASED, accelerator.GetKeyCode(),
accelerator.modifiers(), 0, 0);
NotifyClick(key_event);
return true;
@@ -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.GetKeyCode() == ui::VKEY_SPACE) {
+ if (e.key_code() == ui::VKEY_SPACE) {
SetState(BS_PUSHED);
- } else if (e.GetKeyCode() == ui::VKEY_RETURN) {
+ } else if (e.key_code() == 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.GetKeyCode() != ui::VKEY_SPACE))
+ if ((state_ == BS_DISABLED) || (e.key_code() != 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 0cd933e..766b3dc 100644
--- a/views/controls/button/menu_button.cc
+++ b/views/controls/button/menu_button.cc
@@ -220,14 +220,18 @@ void MenuButton::OnMouseReleased(const MouseEvent& e,
}
bool MenuButton::OnKeyPressed(const KeyEvent& e) {
- 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;
+ 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;
}
return false;
}
diff --git a/views/controls/button/native_button.cc b/views/controls/button/native_button.cc
index 65f6e0b..b822f51 100644
--- a/views/controls/button/native_button.cc
+++ b/views/controls/button/native_button.cc
@@ -116,9 +116,9 @@ void NativeButton::ButtonPressed() {
gfx::Point cursor_point = Screen::GetCursorScreenPoint();
#endif
- views::MouseEvent event(views::Event::ET_MOUSE_RELEASED,
+ views::MouseEvent event(ui::ET_MOUSE_RELEASED,
cursor_point.x(), cursor_point.y(),
- views::Event::EF_LEFT_BUTTON_DOWN);
+ ui::EF_LEFT_BUTTON_DOWN);
NotifyClick(event);
}
@@ -192,9 +192,9 @@ bool NativeButton::AcceleratorPressed(const Accelerator& accelerator) {
#elif defined(OS_LINUX)
gfx::Point cursor_point = Screen::GetCursorScreenPoint();
#endif
- views::MouseEvent event(views::Event::ET_MOUSE_RELEASED,
+ views::MouseEvent event(ui::ET_MOUSE_RELEASED,
cursor_point.x(), cursor_point.y(),
- views::Event::EF_LEFT_BUTTON_DOWN);
+ ui::EF_LEFT_BUTTON_DOWN);
NotifyClick(event);
return true;
}
diff --git a/views/controls/combobox/combobox.cc b/views/controls/combobox/combobox.cc
index 0c7f293..2349bbb 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.GetKeyCode() != ui::VKEY_ESCAPE ||
+ if (e.key_code() != ui::VKEY_ESCAPE ||
e.IsShiftDown() || e.IsControlDown() || e.IsAltDown()) {
return false;
}
diff --git a/views/controls/link.cc b/views/controls/link.cc
index ab48bc2..de7512b 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.GetFlags());
+ controller_->LinkActivated(this, e.flags());
}
}
bool Link::OnKeyPressed(const KeyEvent& e) {
- bool activate = ((e.GetKeyCode() == ui::VKEY_SPACE) ||
- (e.GetKeyCode() == ui::VKEY_RETURN));
+ bool activate = ((e.key_code() == ui::VKEY_SPACE) ||
+ (e.key_code() == ui::VKEY_RETURN));
if (!activate)
return false;
@@ -137,15 +137,15 @@ bool Link::OnKeyPressed(const KeyEvent& e) {
RequestFocus();
if (controller_)
- controller_->LinkActivated(this, e.GetFlags());
+ controller_->LinkActivated(this, e.flags());
return true;
}
bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& e) {
// Make sure we don't process space or enter as accelerators.
- return (e.GetKeyCode() == ui::VKEY_SPACE) ||
- (e.GetKeyCode() == ui::VKEY_RETURN);
+ return (e.key_code() == ui::VKEY_SPACE) ||
+ (e.key_code() == ui::VKEY_RETURN);
}
AccessibilityTypes::Role Link::GetAccessibleRole() {
@@ -165,7 +165,7 @@ void Link::SetEnabled(bool f) {
}
}
-gfx::NativeCursor Link::GetCursorForPoint(Event::EventType event_type,
+gfx::NativeCursor Link::GetCursorForPoint(ui::EventType event_type,
const gfx::Point& p) {
if (!enabled_)
return NULL;
diff --git a/views/controls/link.h b/views/controls/link.h
index ab0c5c3..4c9cb8f 100644
--- a/views/controls/link.h
+++ b/views/controls/link.h
@@ -60,7 +60,7 @@ class Link : public Label {
// Set whether the link is enabled.
virtual void SetEnabled(bool f);
- virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type,
+ virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type,
const gfx::Point& p);
virtual std::string GetClassName() const;
diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc
index 660f8ef..ee41789 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.GetFlags() == MouseEvent::EF_LEFT_BUTTON_DOWN))) {
+ (event.flags() == ui::EF_LEFT_BUTTON_DOWN))) {
if (active_mouse_view_) {
SendMouseReleaseToActiveView(source, event, false);
return;
}
if (part.menu->GetDelegate()->IsTriggerableEvent(event)) {
- Accept(part.menu, event.GetFlags());
+ Accept(part.menu, event.flags());
return;
}
} else if (part.type == MenuPart::MENU_ITEM) {
@@ -1780,7 +1780,7 @@ void MenuController::UpdateActiveMouseView(SubmenuView* event_source,
if (target != active_mouse_view_) {
if (active_mouse_view_) {
// Send a mouse release with cancel set to true.
- MouseEvent release_event(Event::ET_MOUSE_RELEASED, -1, -1, 0);
+ MouseEvent release_event(ui::ET_MOUSE_RELEASED, -1, -1, 0);
active_mouse_view_->OnMouseReleased(release_event, true);
active_mouse_view_ = NULL;
@@ -1789,13 +1789,13 @@ void MenuController::UpdateActiveMouseView(SubmenuView* event_source,
if (active_mouse_view_) {
gfx::Point target_point(target_menu_loc);
View::ConvertPointToView(target_menu, active_mouse_view_, &target_point);
- MouseEvent mouse_entered_event(MouseEvent::ET_MOUSE_ENTERED,
+ MouseEvent mouse_entered_event(ui::ET_MOUSE_ENTERED,
target_point.x(), target_point.y(), 0);
active_mouse_view_->OnMouseEntered(mouse_entered_event);
- MouseEvent mouse_pressed_event(MouseEvent::ET_MOUSE_PRESSED,
+ MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED,
target_point.x(), target_point.y(),
- event.GetFlags());
+ event.flags());
active_mouse_view_->OnMousePressed(mouse_pressed_event);
}
}
@@ -1803,9 +1803,9 @@ void MenuController::UpdateActiveMouseView(SubmenuView* event_source,
if (active_mouse_view_) {
gfx::Point target_point(target_menu_loc);
View::ConvertPointToView(target_menu, active_mouse_view_, &target_point);
- MouseEvent mouse_dragged_event(MouseEvent::ET_MOUSE_DRAGGED,
+ MouseEvent mouse_dragged_event(ui::ET_MOUSE_DRAGGED,
target_point.x(), target_point.y(),
- event.GetFlags());
+ event.flags());
active_mouse_view_->OnMouseDragged(mouse_dragged_event);
}
}
@@ -1820,8 +1820,8 @@ void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source,
View::ConvertPointToScreen(event_source->GetScrollViewContainer(),
&target_loc);
View::ConvertPointToView(NULL, active_mouse_view_, &target_loc);
- MouseEvent release_event(Event::ET_MOUSE_RELEASED, target_loc.x(),
- target_loc.y(), event.GetFlags());
+ MouseEvent release_event(ui::ET_MOUSE_RELEASED, target_loc.x(),
+ target_loc.y(), event.flags());
// 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_;
@@ -1833,7 +1833,7 @@ void MenuController::SendMouseReleaseToActiveView() {
if (!active_mouse_view_)
return;
- MouseEvent release_event(Event::ET_MOUSE_RELEASED, -1, -1, 0);
+ MouseEvent release_event(ui::ET_MOUSE_RELEASED, -1, -1, 0);
// 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 56bd103..8a1f079 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.GetOffset() / WHEEL_DELTA);
+ int delta = abs(e.offset() / WHEEL_DELTA);
#elif defined(OS_LINUX)
- int delta = abs(e.GetOffset());
+ int delta = abs(e.offset());
#endif
- for (bool scroll_up = (e.GetOffset() > 0); delta != 0; --delta) {
+ for (bool scroll_up = (e.offset() > 0); delta != 0; --delta) {
int scroll_target;
if (scroll_up) {
if (GetMenuItemAt(first_vis_index)->y() == vis_bounds.y()) {
diff --git a/views/controls/resize_area.cc b/views/controls/resize_area.cc
index 3a0fd65..b3897bb 100644
--- a/views/controls/resize_area.cc
+++ b/views/controls/resize_area.cc
@@ -34,7 +34,7 @@ std::string ResizeArea::GetClassName() const {
return kViewClassName;
}
-gfx::NativeCursor ResizeArea::GetCursorForPoint(Event::EventType event_type,
+gfx::NativeCursor ResizeArea::GetCursorForPoint(ui::EventType event_type,
const gfx::Point& p) {
if (!enabled_)
return NULL;
diff --git a/views/controls/resize_area.h b/views/controls/resize_area.h
index 4f398ca..9adb60c 100644
--- a/views/controls/resize_area.h
+++ b/views/controls/resize_area.h
@@ -42,7 +42,7 @@ class ResizeArea : public View {
// Overridden from views::View:
virtual std::string GetClassName() const;
- virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type,
+ virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type,
const gfx::Point& p);
virtual bool OnMousePressed(const views::MouseEvent& event);
virtual bool OnMouseDragged(const views::MouseEvent& event);
diff --git a/views/controls/scrollbar/bitmap_scroll_bar.cc b/views/controls/scrollbar/bitmap_scroll_bar.cc
index cf0e919..262545e 100644
--- a/views/controls/scrollbar/bitmap_scroll_bar.cc
+++ b/views/controls/scrollbar/bitmap_scroll_bar.cc
@@ -74,9 +74,9 @@ class AutorepeatButton : public ImageButton {
#elif defined(OS_LINUX)
gfx::Point cursor_point = Screen::GetCursorScreenPoint();
#endif
- views::MouseEvent event(views::Event::ET_MOUSE_RELEASED,
+ views::MouseEvent event(ui::ET_MOUSE_RELEASED,
cursor_point.x(), cursor_point.y(),
- views::Event::EF_LEFT_BUTTON_DOWN);
+ ui::EF_LEFT_BUTTON_DOWN);
Button::NotifyClick(event);
}
@@ -491,13 +491,13 @@ void BitmapScrollBar::OnMouseReleased(const MouseEvent& event, bool canceled) {
}
bool BitmapScrollBar::OnMouseWheel(const MouseWheelEvent& event) {
- ScrollByContentsOffset(event.GetOffset());
+ ScrollByContentsOffset(event.offset());
return true;
}
bool BitmapScrollBar::OnKeyPressed(const KeyEvent& event) {
ScrollAmount amount = SCROLL_NONE;
- switch (event.GetKeyCode()) {
+ switch (event.key_code()) {
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 73bb109..dc1a9b6 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.GetKeyCode()) {
+ switch (event.key_code()) {
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.GetOffset()); // e.GetOffset() > 0 means scroll up.
+ MoveBy(-e.offset()); // 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 44d8bf6..01cd5f8 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.GetKeyCode()) {
+ switch (event.key_code()) {
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.GetOffset());
+ sb_container_->ScrollWithOffset(e.offset());
return true;
}
diff --git a/views/controls/single_split_view.cc b/views/controls/single_split_view.cc
index ad2a59a..2b076d6 100644
--- a/views/controls/single_split_view.cc
+++ b/views/controls/single_split_view.cc
@@ -91,7 +91,7 @@ gfx::Size SingleSplitView::GetPreferredSize() {
}
gfx::NativeCursor SingleSplitView::GetCursorForPoint(
- Event::EventType event_type,
+ ui::EventType event_type,
const gfx::Point& p) {
if (IsPointInDivider(p)) {
#if defined(OS_WIN)
diff --git a/views/controls/single_split_view.h b/views/controls/single_split_view.h
index 57f4cc3..dc69c67 100644
--- a/views/controls/single_split_view.h
+++ b/views/controls/single_split_view.h
@@ -49,7 +49,7 @@ class SingleSplitView : public views::View {
virtual gfx::Size GetPreferredSize();
// Overriden to return a resize cursor when over the divider.
- virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type,
+ virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type,
const gfx::Point& p);
Orientation orientation() const {
diff --git a/views/controls/single_split_view_unittest.cc b/views/controls/single_split_view_unittest.cc
index a42e3b8..65fbb00 100644
--- a/views/controls/single_split_view_unittest.cc
+++ b/views/controls/single_split_view_unittest.cc
@@ -146,25 +146,25 @@ TEST(SingleSplitViewTest, MouseDrag) {
// Drag divider to the right, in 2 steps.
MouseEvent mouse_pressed(
- Event::ET_MOUSE_PRESSED, 7, kInitialDividerOffset + kMouseOffset, 0);
+ ui::ET_MOUSE_PRESSED, 7, kInitialDividerOffset + kMouseOffset, 0);
ASSERT_TRUE(split.OnMousePressed(mouse_pressed));
EXPECT_EQ(kInitialDividerOffset, split.divider_offset());
MouseEvent mouse_dragged_1(
- Event::ET_MOUSE_DRAGGED, 5,
+ ui::ET_MOUSE_DRAGGED, 5,
kInitialDividerOffset + kMouseOffset + kMouseMoveDelta, 0);
ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_1));
EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta, split.divider_offset());
MouseEvent mouse_dragged_2(
- Event::ET_MOUSE_DRAGGED, 6,
+ ui::ET_MOUSE_DRAGGED, 6,
kInitialDividerOffset + kMouseOffset + kMouseMoveDelta * 2, 0);
ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_2));
EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2,
split.divider_offset());
MouseEvent mouse_released(
- Event::ET_MOUSE_RELEASED, 7,
+ ui::ET_MOUSE_RELEASED, 7,
kInitialDividerOffset + kMouseOffset + kMouseMoveDelta * 2, 0);
split.OnMouseReleased(mouse_released, false);
EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2,
diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc
index 11649ebf..529fed1 100644
--- a/views/controls/textfield/native_textfield_views.cc
+++ b/views/controls/textfield/native_textfield_views.cc
@@ -139,7 +139,7 @@ void NativeTextfieldViews::WillLoseFocus() {
}
gfx::NativeCursor NativeTextfieldViews::GetCursorForPoint(
- Event::EventType event_type,
+ ui::EventType event_type,
const gfx::Point& p) {
#if defined(OS_WIN)
static HCURSOR ibeam = LoadCursor(NULL, IDC_IBEAM);
@@ -531,8 +531,8 @@ void NativeTextfieldViews::PaintTextAndCursor(gfx::Canvas* canvas) {
bool NativeTextfieldViews::HandleKeyEvent(const KeyEvent& key_event) {
// TODO(oshima): handle IME.
- if (key_event.GetType() == views::Event::ET_KEY_PRESSED) {
- ui::KeyboardCode key_code = key_event.GetKeyCode();
+ if (key_event.type() == ui::ET_KEY_PRESSED) {
+ ui::KeyboardCode key_code = key_event.key_code();
// 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.GetKeyCode();
+ ui::KeyboardCode key_code = key_event.key_code();
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.GetTimeStamp() - last_mouse_press_time_;
+ base::TimeDelta time_delta = e.time_stamp() - last_mouse_press_time_;
gfx::Point location_delta = e.location().Subtract(last_mouse_press_location_);
- last_mouse_press_time_ = e.GetTimeStamp();
+ last_mouse_press_time_ = e.time_stamp();
last_mouse_press_location_ = e.location();
if (e.IsLeftMouseButton()) {
if (!ExceededDragThreshold(location_delta.x(), location_delta.y())
diff --git a/views/controls/textfield/native_textfield_views.h b/views/controls/textfield/native_textfield_views.h
index 4bf2be0..3a961fd 100644
--- a/views/controls/textfield/native_textfield_views.h
+++ b/views/controls/textfield/native_textfield_views.h
@@ -57,7 +57,7 @@ class NativeTextfieldViews : public views::View,
virtual void WillGainFocus();
virtual void DidGainFocus();
virtual void WillLoseFocus();
- virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type,
+ virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type,
const gfx::Point& p);
// views::ContextMenuController overrides:
diff --git a/views/controls/textfield/native_textfield_views_unittest.cc b/views/controls/textfield/native_textfield_views_unittest.cc
index b593d1d..3c35e59 100644
--- a/views/controls/textfield/native_textfield_views_unittest.cc
+++ b/views/controls/textfield/native_textfield_views_unittest.cc
@@ -113,10 +113,10 @@ class NativeTextfieldViewsTest : public ViewsTestBase,
bool shift,
bool control,
bool capslock) {
- int flags = (shift ? KeyEvent::EF_SHIFT_DOWN : 0) |
- (control ? KeyEvent::EF_CONTROL_DOWN : 0) |
- (capslock ? KeyEvent::EF_CAPS_LOCK_DOWN : 0);
- KeyEvent event(KeyEvent::ET_KEY_PRESSED, key_code, flags, 1, 0);
+ int flags = (shift ? ui::EF_SHIFT_DOWN : 0) |
+ (control ? ui::EF_CONTROL_DOWN : 0) |
+ (capslock ? ui::EF_CAPS_LOCK_DOWN : 0);
+ KeyEvent event(ui::ET_KEY_PRESSED, key_code, flags, 1, 0);
return textfield_->OnKeyPressed(event);
}
@@ -435,7 +435,7 @@ TEST_F(NativeTextfieldViewsTest, ContextMenuDisplayTest) {
TEST_F(NativeTextfieldViewsTest, DoubleAndTripleClickTest) {
InitTextfield(Textfield::STYLE_DEFAULT);
textfield_->SetText(ASCIIToUTF16("hello world"));
- MouseEvent me(MouseEvent::ET_MOUSE_PRESSED, 0, 0, Event::EF_LEFT_BUTTON_DOWN);
+ MouseEvent me(ui::ET_MOUSE_PRESSED, 0, 0, ui::EF_LEFT_BUTTON_DOWN);
EXPECT_EQ(NativeTextfieldViews::NONE, GetClickState());
// Test for double click.
diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc
index 681b15f..c229eb90 100644
--- a/views/controls/textfield/native_textfield_win.cc
+++ b/views/controls/textfield/native_textfield_win.cc
@@ -940,22 +940,22 @@ void NativeTextfieldWin::HandleKeystroke(UINT message,
Textfield::Controller* controller = textfield_->GetController();
bool handled = false;
if (controller) {
- Event::EventType type;
+ ui::EventType type;
switch (message) {
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_CHAR:
case WM_SYSCHAR:
- type = Event::ET_KEY_PRESSED;
+ type = ui::ET_KEY_PRESSED;
break;
case WM_KEYUP:
case WM_SYSKEYUP:
- type = Event::ET_KEY_RELEASED;
+ type = ui::ET_KEY_RELEASED;
break;
default:
NOTREACHED() << "Unknown message:" << message;
// Passing through to avoid crash on release build.
- type = Event::ET_KEY_PRESSED;
+ type = ui::ET_KEY_PRESSED;
}
KeyEvent key_event(type,
ui::KeyboardCodeForWindowsKeyCode(key),
diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc
index 1b4461c..9028f88 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.GetKeyCode();
+ ui::KeyboardCode key = e.key_code();
if (key == ui::VKEY_BACK)
return true; // We'll handle BackSpace ourselves.
diff --git a/views/events/event.cc b/views/events/event.cc
index e5e0a5a..565165b 100644
--- a/views/events/event.cc
+++ b/views/events/event.cc
@@ -8,7 +8,7 @@
namespace views {
-Event::Event(EventType type, int flags)
+Event::Event(ui::EventType type, int flags)
: type_(type),
time_stamp_(base::Time::NowFromSystemTime()),
flags_(flags) {
@@ -21,7 +21,7 @@ LocatedEvent::LocatedEvent(const LocatedEvent& model, View* from, View* to)
View::ConvertPointToView(from, to, &location_);
}
-KeyEvent::KeyEvent(EventType type, ui::KeyboardCode key_code,
+KeyEvent::KeyEvent(ui::EventType type, ui::KeyboardCode key_code,
int event_flags, int repeat_count, int message_flags)
: Event(type, event_flags),
key_code_(key_code),
@@ -29,7 +29,7 @@ KeyEvent::KeyEvent(EventType type, ui::KeyboardCode key_code,
message_flags_(message_flags) {
}
-MouseEvent::MouseEvent(EventType type,
+MouseEvent::MouseEvent(ui::EventType type,
View* from,
View* to,
const gfx::Point &l,
@@ -44,13 +44,13 @@ MouseEvent::MouseEvent(const MouseEvent& model, View* from, View* to)
}
#if defined(TOUCH_UI)
-TouchEvent::TouchEvent(EventType type, int x, int y, int flags, int touch_id)
+TouchEvent::TouchEvent(ui::EventType type, int x, int y, int flags, int touch_id)
: LocatedEvent(type, gfx::Point(x, y), flags),
touch_id_(touch_id) {
}
-TouchEvent::TouchEvent(EventType type,
+TouchEvent::TouchEvent(ui::EventType type,
View* from,
View* to,
const gfx::Point& l,
diff --git a/views/events/event.h b/views/events/event.h
index b16371e..385e49c 100644
--- a/views/events/event.h
+++ b/views/events/event.h
@@ -8,8 +8,10 @@
#include "base/basictypes.h"
#include "base/time.h"
+#include "ui/base/events.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;
@@ -42,95 +44,36 @@ class View;
////////////////////////////////////////////////////////////////////////////////
class Event {
public:
- // Event types. (prefixed because of a conflict with windows headers)
- enum EventType { ET_UNKNOWN = 0,
- ET_MOUSE_PRESSED,
- ET_MOUSE_DRAGGED,
- ET_MOUSE_RELEASED,
- ET_MOUSE_MOVED,
- ET_MOUSE_ENTERED,
- ET_MOUSE_EXITED,
- ET_KEY_PRESSED,
- ET_KEY_RELEASED,
- ET_MOUSEWHEEL,
-#if defined(TOUCH_UI)
- ET_TOUCH_RELEASED,
- ET_TOUCH_PRESSED,
- ET_TOUCH_MOVED,
- ET_TOUCH_STATIONARY,
- ET_TOUCH_CANCELLED,
-#endif
- ET_DROP_TARGET_EVENT };
-
- // Event flags currently supported. Although this is a "views"
- // file, this header is used on non-views platforms (e.g. OSX). For
- // example, these EventFlags are used by the automation provider for
- // all platforms.
- enum EventFlags { EF_CAPS_LOCK_DOWN = 1 << 0,
- EF_SHIFT_DOWN = 1 << 1,
- EF_CONTROL_DOWN = 1 << 2,
- EF_ALT_DOWN = 1 << 3,
- EF_LEFT_BUTTON_DOWN = 1 << 4,
- EF_MIDDLE_BUTTON_DOWN = 1 << 5,
- EF_RIGHT_BUTTON_DOWN = 1 << 6,
- EF_COMMAND_DOWN = 1 << 7, // Only useful on OSX
- };
-
- // 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;
- }
-
- // 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;
- }
+ const NativeEvent& native_event() const { return native_event_; }
+ ui::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; }
+
+ // The following methods return true if the respective keys were pressed at
+ // the time the event was created.
+ bool IsShiftDown() const { return (flags_ & ui::EF_SHIFT_DOWN) != 0; }
+ bool IsControlDown() const { return (flags_ & ui::EF_CONTROL_DOWN) != 0; }
+ bool IsCapsLockDown() const { return (flags_ & ui::EF_CAPS_LOCK_DOWN) != 0; }
+ bool IsAltDown() const { return (flags_ & ui::EF_ALT_DOWN) != 0; }
bool IsMouseEvent() const {
- return type_ == ET_MOUSE_PRESSED ||
- type_ == ET_MOUSE_DRAGGED ||
- type_ == ET_MOUSE_RELEASED ||
- type_ == ET_MOUSE_MOVED ||
- type_ == ET_MOUSE_ENTERED ||
- type_ == ET_MOUSE_EXITED ||
- type_ == ET_MOUSEWHEEL;
+ return type_ == ui::ET_MOUSE_PRESSED ||
+ type_ == ui::ET_MOUSE_DRAGGED ||
+ type_ == ui::ET_MOUSE_RELEASED ||
+ type_ == ui::ET_MOUSE_MOVED ||
+ type_ == ui::ET_MOUSE_ENTERED ||
+ type_ == ui::ET_MOUSE_EXITED ||
+ type_ == ui::ET_MOUSEWHEEL;
}
#if defined(TOUCH_UI)
bool IsTouchEvent() const {
- return type_ == ET_TOUCH_RELEASED ||
- type_ == ET_TOUCH_PRESSED ||
- type_ == ET_TOUCH_MOVED ||
- type_ == ET_TOUCH_STATIONARY ||
- type_ == ET_TOUCH_CANCELLED;
+ return type_ == ui::ET_TOUCH_RELEASED ||
+ type_ == ui::ET_TOUCH_PRESSED ||
+ type_ == ui::ET_TOUCH_MOVED ||
+ type_ == ui::ET_TOUCH_STATIONARY ||
+ type_ == ui::ET_TOUCH_CANCELLED;
}
#endif
@@ -146,18 +89,20 @@ class Event {
#endif
protected:
- Event(EventType type, int flags);
+ Event(ui::EventType type, int flags);
Event(const Event& model)
- : type_(model.GetType()),
- time_stamp_(model.GetTimeStamp()),
- flags_(model.GetFlags()) {
+ : native_event_(model.native_event()),
+ type_(model.type()),
+ time_stamp_(model.time_stamp()),
+ flags_(model.flags()) {
}
private:
void operator=(const Event&);
- EventType type_;
+ NativeEvent native_event_;
+ ui::EventType type_;
base::Time time_stamp_;
int flags_;
};
@@ -172,7 +117,7 @@ class Event {
////////////////////////////////////////////////////////////////////////////////
class LocatedEvent : public Event {
public:
- LocatedEvent(EventType type, const gfx::Point& location, int flags)
+ LocatedEvent(ui::EventType type, const gfx::Point& location, int flags)
: Event(type, flags),
location_(location) {
}
@@ -182,20 +127,9 @@ class LocatedEvent : public Event {
// from 'from' coordinate system to 'to' coordinate system
LocatedEvent(const LocatedEvent& model, View* from, View* to);
- // 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_;
- }
+ int x() const { return location_.x(); }
+ int y() const { return location_.y(); }
+ const gfx::Point& location() const { return location_; }
private:
gfx::Point location_;
@@ -210,21 +144,15 @@ class LocatedEvent : public Event {
////////////////////////////////////////////////////////////////////////////////
class MouseEvent : public LocatedEvent {
public:
- // Flags specific to mouse events
- enum MouseEventFlags {
- EF_IS_DOUBLE_CLICK = 1 << 16,
- EF_IS_NON_CLIENT = 1 << 17
- };
-
// Create a new mouse event
- MouseEvent(EventType type, int x, int y, int flags)
+ MouseEvent(ui::EventType type, int x, int y, int flags)
: LocatedEvent(type, gfx::Point(x, y), flags) {
}
// Create a new mouse event from a type and a point. If from / to views
// are provided, the point will be converted from 'from' coordinate system to
// 'to' coordinate system.
- MouseEvent(EventType type,
+ MouseEvent(ui::EventType type,
View* from,
View* to,
const gfx::Point &l,
@@ -242,30 +170,30 @@ class MouseEvent : public LocatedEvent {
// Conveniences to quickly test what button is down
bool IsOnlyLeftMouseButton() const {
- return (GetFlags() & EF_LEFT_BUTTON_DOWN) &&
- !(GetFlags() & (EF_MIDDLE_BUTTON_DOWN | EF_RIGHT_BUTTON_DOWN));
+ return (flags() & ui::EF_LEFT_BUTTON_DOWN) &&
+ !(flags() & (ui::EF_MIDDLE_BUTTON_DOWN | ui::EF_RIGHT_BUTTON_DOWN));
}
bool IsLeftMouseButton() const {
- return (GetFlags() & EF_LEFT_BUTTON_DOWN) != 0;
+ return (flags() & ui::EF_LEFT_BUTTON_DOWN) != 0;
}
bool IsOnlyMiddleMouseButton() const {
- return (GetFlags() & EF_MIDDLE_BUTTON_DOWN) &&
- !(GetFlags() & (EF_LEFT_BUTTON_DOWN | EF_RIGHT_BUTTON_DOWN));
+ return (flags() & ui::EF_MIDDLE_BUTTON_DOWN) &&
+ !(flags() & (ui::EF_LEFT_BUTTON_DOWN | ui::EF_RIGHT_BUTTON_DOWN));
}
bool IsMiddleMouseButton() const {
- return (GetFlags() & EF_MIDDLE_BUTTON_DOWN) != 0;
+ return (flags() & ui::EF_MIDDLE_BUTTON_DOWN) != 0;
}
bool IsOnlyRightMouseButton() const {
- return (GetFlags() & EF_RIGHT_BUTTON_DOWN) &&
- !(GetFlags() & (EF_LEFT_BUTTON_DOWN | EF_MIDDLE_BUTTON_DOWN));
+ return (flags() & ui::EF_RIGHT_BUTTON_DOWN) &&
+ !(flags() & (ui::EF_LEFT_BUTTON_DOWN | ui::EF_MIDDLE_BUTTON_DOWN));
}
bool IsRightMouseButton() const {
- return (GetFlags() & EF_RIGHT_BUTTON_DOWN) != 0;
+ return (flags() & ui::EF_RIGHT_BUTTON_DOWN) != 0;
}
private:
@@ -285,12 +213,12 @@ class MouseEvent : public LocatedEvent {
class TouchEvent : public LocatedEvent {
public:
// Create a new touch event.
- TouchEvent(EventType type, int x, int y, int flags, int touch_id);
+ TouchEvent(ui::EventType type, int x, int y, int flags, int touch_id);
// Create a new touch event from a type and a point. If from / to views
// are provided, the point will be converted from 'from' coordinate system to
// 'to' coordinate system.
- TouchEvent(EventType type,
+ TouchEvent(ui::EventType type,
View* from,
View* to,
const gfx::Point& l,
@@ -306,10 +234,7 @@ class TouchEvent : public LocatedEvent {
explicit TouchEvent(XEvent* xev);
#endif
- // Return the touch point for this event.
- bool identity() const {
- return touch_id_;
- }
+ bool identity() const { return touch_id_; }
private:
// The identity (typically finger) of the touch starting at 0 and incrementing
@@ -331,14 +256,14 @@ class TouchEvent : public LocatedEvent {
class KeyEvent : public Event {
public:
// Create a new key event
- KeyEvent(EventType type,
+ KeyEvent(ui::EventType type,
ui::KeyboardCode key_code,
int event_flags,
int repeat_count,
int message_flags);
#if defined(OS_WIN)
- KeyEvent(EventType type,
+ KeyEvent(ui::EventType type,
ui::KeyboardCode key_code,
int event_flags,
int repeat_count,
@@ -355,25 +280,15 @@ class KeyEvent : public Event {
explicit KeyEvent(XEvent* xevent);
#endif
- // 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_;
- }
+ ui::KeyboardCode key_code() const { return key_code_; }
#if defined(OS_WIN)
bool IsExtendedKey() const;
- UINT message() const {
- return message_;
- }
+ UINT message() const { return message_; }
#endif
- int GetRepeatCount() const {
- return repeat_count_;
- }
+ int repeat_count() const { return repeat_count_; }
#if defined(OS_WIN)
static int GetKeyStateFlags();
@@ -404,7 +319,7 @@ class MouseWheelEvent : public LocatedEvent {
public:
// Create a new key event
MouseWheelEvent(int offset, int x, int y, int flags)
- : LocatedEvent(ET_MOUSEWHEEL, gfx::Point(x, y), flags),
+ : LocatedEvent(ui::ET_MOUSEWHEEL, gfx::Point(x, y), flags),
offset_(offset) {
}
@@ -412,9 +327,7 @@ class MouseWheelEvent : public LocatedEvent {
explicit MouseWheelEvent(XEvent* xev);
#endif
- int GetOffset() const {
- return offset_;
- }
+ int offset() const { return offset_; }
private:
int offset_;
@@ -436,19 +349,19 @@ class DropTargetEvent : public LocatedEvent {
int x,
int y,
int source_operations)
- : LocatedEvent(ET_DROP_TARGET_EVENT, gfx::Point(x, y), 0),
+ : LocatedEvent(ui::ET_DROP_TARGET_EVENT, gfx::Point(x, y), 0),
data_(data),
source_operations_(source_operations) {
}
- // Data associated with the drag/drop session.
- const OSExchangeData& GetData() const { return data_; }
-
- // Bitmask of supported ui::DragDropTypes::DragOperation by the source.
- int GetSourceOperations() const { return 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_;
+
+ // Bitmask of supported ui::DragDropTypes::DragOperation by the source.
int source_operations_;
DISALLOW_COPY_AND_ASSIGN(DropTargetEvent);
diff --git a/views/events/event_gtk.cc b/views/events/event_gtk.cc
index e06ee32..b74621a 100644
--- a/views/events/event_gtk.cc
+++ b/views/events/event_gtk.cc
@@ -12,7 +12,7 @@ namespace views {
KeyEvent::KeyEvent(const GdkEventKey* event)
: Event(event->type == GDK_KEY_PRESS ?
- Event::ET_KEY_PRESSED : Event::ET_KEY_RELEASED,
+ ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED,
GetFlagsFromGdkState(event->state)),
// TODO(erg): All these values are iffy.
key_code_(ui::WindowsKeyCodeForGdkKeyCode(event->keyval)),
@@ -28,19 +28,19 @@ KeyEvent::KeyEvent(const GdkEventKey* event)
int Event::GetFlagsFromGdkState(int state) {
int flags = 0;
if (state & GDK_LOCK_MASK)
- flags |= Event::EF_CAPS_LOCK_DOWN;
+ flags |= ui::EF_CAPS_LOCK_DOWN;
if (state & GDK_CONTROL_MASK)
- flags |= Event::EF_CONTROL_DOWN;
+ flags |= ui::EF_CONTROL_DOWN;
if (state & GDK_SHIFT_MASK)
- flags |= Event::EF_SHIFT_DOWN;
+ flags |= ui::EF_SHIFT_DOWN;
if (state & GDK_MOD1_MASK)
- flags |= Event::EF_ALT_DOWN;
+ flags |= ui::EF_ALT_DOWN;
if (state & GDK_BUTTON1_MASK)
- flags |= Event::EF_LEFT_BUTTON_DOWN;
+ flags |= ui::EF_LEFT_BUTTON_DOWN;
if (state & GDK_BUTTON2_MASK)
- flags |= Event::EF_MIDDLE_BUTTON_DOWN;
+ flags |= ui::EF_MIDDLE_BUTTON_DOWN;
if (state & GDK_BUTTON3_MASK)
- flags |= Event::EF_RIGHT_BUTTON_DOWN;
+ flags |= ui::EF_RIGHT_BUTTON_DOWN;
return flags;
}
diff --git a/views/events/event_win.cc b/views/events/event_win.cc
index fd33f9f..654d4c2 100644
--- a/views/events/event_win.cc
+++ b/views/events/event_win.cc
@@ -8,7 +8,7 @@
namespace views {
-KeyEvent::KeyEvent(EventType type, ui::KeyboardCode key_code,
+KeyEvent::KeyEvent(ui::EventType type, ui::KeyboardCode key_code,
int event_flags, int repeat_count, int message_flags,
UINT message)
: Event(type, event_flags),
@@ -21,11 +21,11 @@ KeyEvent::KeyEvent(EventType type, ui::KeyboardCode key_code,
int Event::GetWindowsFlags() const {
// TODO: need support for x1/x2.
int result = 0;
- result |= (flags_ & EF_SHIFT_DOWN) ? MK_SHIFT : 0;
- result |= (flags_ & EF_CONTROL_DOWN) ? MK_CONTROL : 0;
- result |= (flags_ & EF_LEFT_BUTTON_DOWN) ? MK_LBUTTON : 0;
- result |= (flags_ & EF_MIDDLE_BUTTON_DOWN) ? MK_MBUTTON : 0;
- result |= (flags_ & EF_RIGHT_BUTTON_DOWN) ? MK_RBUTTON : 0;
+ result |= (flags_ & ui::EF_SHIFT_DOWN) ? MK_SHIFT : 0;
+ result |= (flags_ & ui::EF_CONTROL_DOWN) ? MK_CONTROL : 0;
+ result |= (flags_ & ui::EF_LEFT_BUTTON_DOWN) ? MK_LBUTTON : 0;
+ result |= (flags_ & ui::EF_MIDDLE_BUTTON_DOWN) ? MK_MBUTTON : 0;
+ result |= (flags_ & ui::EF_RIGHT_BUTTON_DOWN) ? MK_RBUTTON : 0;
return result;
}
@@ -33,17 +33,17 @@ int Event::GetWindowsFlags() const {
int Event::ConvertWindowsFlags(UINT win_flags) {
int r = 0;
if (win_flags & MK_CONTROL)
- r |= EF_CONTROL_DOWN;
+ r |= ui::EF_CONTROL_DOWN;
if (win_flags & MK_SHIFT)
- r |= EF_SHIFT_DOWN;
+ r |= ui::EF_SHIFT_DOWN;
if (GetKeyState(VK_MENU) < 0)
- r |= EF_ALT_DOWN;
+ r |= ui::EF_ALT_DOWN;
if (win_flags & MK_LBUTTON)
- r |= EF_LEFT_BUTTON_DOWN;
+ r |= ui::EF_LEFT_BUTTON_DOWN;
if (win_flags & MK_MBUTTON)
- r |= EF_MIDDLE_BUTTON_DOWN;
+ r |= ui::EF_MIDDLE_BUTTON_DOWN;
if (win_flags & MK_RBUTTON)
- r |= EF_RIGHT_BUTTON_DOWN;
+ r |= ui::EF_RIGHT_BUTTON_DOWN;
return r;
}
@@ -54,11 +54,11 @@ int KeyEvent::GetKeyStateFlags() {
// states.
int flags = 0;
if (GetKeyState(VK_MENU) & 0x80)
- flags |= Event::EF_ALT_DOWN;
+ flags |= ui::EF_ALT_DOWN;
if (GetKeyState(VK_SHIFT) & 0x80)
- flags |= Event::EF_SHIFT_DOWN;
+ flags |= ui::EF_SHIFT_DOWN;
if (GetKeyState(VK_CONTROL) & 0x80)
- flags |= Event::EF_CONTROL_DOWN;
+ flags |= ui::EF_CONTROL_DOWN;
return flags;
}
diff --git a/views/events/event_x.cc b/views/events/event_x.cc
index 9c51c72..cce5999 100644
--- a/views/events/event_x.cc
+++ b/views/events/event_x.cc
@@ -23,19 +23,19 @@ static int kWheelScrollAmount = 53;
int GetEventFlagsFromXState(unsigned int state) {
int flags = 0;
if (state & ControlMask)
- flags |= Event::EF_CONTROL_DOWN;
+ flags |= ui::EF_CONTROL_DOWN;
if (state & ShiftMask)
- flags |= Event::EF_SHIFT_DOWN;
+ flags |= ui::EF_SHIFT_DOWN;
if (state & Mod1Mask)
- flags |= Event::EF_ALT_DOWN;
+ flags |= ui::EF_ALT_DOWN;
if (state & LockMask)
- flags |= Event::EF_CAPS_LOCK_DOWN;
+ flags |= ui::EF_CAPS_LOCK_DOWN;
if (state & Button1Mask)
- flags |= Event::EF_LEFT_BUTTON_DOWN;
+ flags |= ui::EF_LEFT_BUTTON_DOWN;
if (state & Button2Mask)
- flags |= Event::EF_MIDDLE_BUTTON_DOWN;
+ flags |= ui::EF_MIDDLE_BUTTON_DOWN;
if (state & Button3Mask)
- flags |= Event::EF_RIGHT_BUTTON_DOWN;
+ flags |= ui::EF_RIGHT_BUTTON_DOWN;
return flags;
}
@@ -51,11 +51,11 @@ int GetEventFlagsFromXState(unsigned int state) {
int GetEventFlagsForButton(int button) {
switch (button) {
case 1:
- return Event::EF_LEFT_BUTTON_DOWN;
+ return ui::EF_LEFT_BUTTON_DOWN;
case 2:
- return Event::EF_MIDDLE_BUTTON_DOWN;
+ return ui::EF_MIDDLE_BUTTON_DOWN;
case 3:
- return Event::EF_RIGHT_BUTTON_DOWN;
+ return ui::EF_RIGHT_BUTTON_DOWN;
}
DLOG(WARNING) << "Unexpected button (" << button << ") received.";
@@ -75,15 +75,15 @@ int GetButtonMaskForX2Event(XIDeviceEvent* xievent) {
return buttonflags;
}
-Event::EventType GetTouchEventType(XEvent* xev) {
+ui::EventType GetTouchEventType(XEvent* xev) {
XGenericEventCookie* cookie = &xev->xcookie;
switch (cookie->evtype) {
case XI_ButtonPress:
- return Event::ET_TOUCH_PRESSED;
+ return ui::ET_TOUCH_PRESSED;
case XI_ButtonRelease:
- return Event::ET_TOUCH_RELEASED;
+ return ui::ET_TOUCH_RELEASED;
case XI_Motion:
- return Event::ET_TOUCH_MOVED;
+ return ui::ET_TOUCH_MOVED;
// Note: We will not generate a _STATIONARY event here. It will be created,
// when necessary, by a RWHVV.
@@ -93,7 +93,7 @@ Event::EventType GetTouchEventType(XEvent* xev) {
// touch-sequence?
}
- return Event::ET_UNKNOWN;
+ return ui::ET_UNKNOWN;
}
gfx::Point GetTouchEventLocation(XEvent* xev) {
@@ -126,35 +126,35 @@ int GetMouseWheelOffset(XEvent* xev) {
return xev->xbutton.button == 4 ? kWheelScrollAmount : -kWheelScrollAmount;
}
-Event::EventType GetMouseEventType(XEvent* xev) {
+ui::EventType GetMouseEventType(XEvent* xev) {
switch (xev->type) {
case ButtonPress:
- return Event::ET_MOUSE_PRESSED;
+ return ui::ET_MOUSE_PRESSED;
case ButtonRelease:
- return Event::ET_MOUSE_RELEASED;
+ return ui::ET_MOUSE_RELEASED;
case MotionNotify:
if (xev->xmotion.state & (Button1Mask | Button2Mask | Button3Mask)) {
- return Event::ET_MOUSE_DRAGGED;
+ return ui::ET_MOUSE_DRAGGED;
}
- return Event::ET_MOUSE_MOVED;
+ return ui::ET_MOUSE_MOVED;
#if defined(HAVE_XINPUT2)
case GenericEvent: {
XIDeviceEvent* xievent =
static_cast<XIDeviceEvent*>(xev->xcookie.data);
switch (xievent->evtype) {
case XI_ButtonPress:
- return Event::ET_MOUSE_PRESSED;
+ return ui::ET_MOUSE_PRESSED;
case XI_ButtonRelease:
- return Event::ET_MOUSE_RELEASED;
+ return ui::ET_MOUSE_RELEASED;
case XI_Motion:
- return GetButtonMaskForX2Event(xievent) ? Event::ET_MOUSE_DRAGGED :
- Event::ET_MOUSE_MOVED;
+ return GetButtonMaskForX2Event(xievent) ? ui::ET_MOUSE_DRAGGED :
+ ui::ET_MOUSE_MOVED;
}
}
#endif
}
- return Event::ET_UNKNOWN;
+ return ui::ET_UNKNOWN;
}
gfx::Point GetMouseEventLocation(XEvent* xev) {
@@ -214,7 +214,7 @@ int GetMouseEventFlags(XEvent* xev) {
KeyEvent::KeyEvent(XEvent* xev)
: Event(xev->type == KeyPress ?
- Event::ET_KEY_PRESSED : Event::ET_KEY_RELEASED,
+ ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED,
GetEventFlagsFromXState(xev->xkey.state)),
key_code_(ui::KeyboardCodeFromXKeyEvent(xev)),
repeat_count_(0),
@@ -229,7 +229,7 @@ MouseEvent::MouseEvent(XEvent* xev)
}
MouseWheelEvent::MouseWheelEvent(XEvent* xev)
- : LocatedEvent(Event::ET_MOUSEWHEEL,
+ : LocatedEvent(ui::ET_MOUSEWHEEL,
GetMouseEventLocation(xev),
GetEventFlagsFromXState(xev->xbutton.state)),
offset_(GetMouseWheelOffset(xev)) {
diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc
index 6dcd040..65cc2e7 100644
--- a/views/focus/accelerator_handler_touch.cc
+++ b/views/focus/accelerator_handler_touch.cc
@@ -99,8 +99,8 @@ bool DispatchX2Event(RootView* root, XEvent* xev) {
if (!touch_event) {
// Show the cursor, and decide whether or not the cursor should be
// automatically hidden after a certain time of inactivity.
- int button_flags = mouseev.GetFlags() & (Event::EF_RIGHT_BUTTON_DOWN |
- Event::EF_MIDDLE_BUTTON_DOWN | Event::EF_LEFT_BUTTON_DOWN);
+ int button_flags = mouseev.GetFlags() & (ui::EF_RIGHT_BUTTON_DOWN |
+ ui::EF_MIDDLE_BUTTON_DOWN | ui::EF_LEFT_BUTTON_DOWN);
bool start_timer = false;
switch (cookie->evtype) {
@@ -110,9 +110,9 @@ bool DispatchX2Event(RootView* root, XEvent* xev) {
case XI_ButtonRelease:
// For a release, start the timer if this was only button pressed
// that is being released.
- if (button_flags == Event::EF_RIGHT_BUTTON_DOWN ||
- button_flags == Event::EF_LEFT_BUTTON_DOWN ||
- button_flags == Event::EF_MIDDLE_BUTTON_DOWN)
+ if (button_flags == ui::EF_RIGHT_BUTTON_DOWN ||
+ button_flags == ui::EF_LEFT_BUTTON_DOWN ||
+ button_flags == ui::EF_MIDDLE_BUTTON_DOWN)
start_timer = true;
break;
case XI_Motion:
@@ -130,7 +130,7 @@ bool DispatchX2Event(RootView* root, XEvent* xev) {
root->OnMouseReleased(mouseev, false);
return true;
case XI_Motion: {
- if (mouseev.GetType() == Event::ET_MOUSE_DRAGGED) {
+ if (mouseev.GetType() == ui::ET_MOUSE_DRAGGED) {
return root->OnMouseDragged(mouseev);
} else {
root->OnMouseMoved(mouseev);
@@ -188,7 +188,7 @@ bool DispatchXEvent(XEvent* xev) {
case MotionNotify: {
MouseEvent mouseev(xev);
- if (mouseev.GetType() == Event::ET_MOUSE_DRAGGED) {
+ if (mouseev.GetType() == ui::ET_MOUSE_DRAGGED) {
return root->OnMouseDragged(mouseev);
} else {
root->OnMouseMoved(mouseev);
diff --git a/views/focus/accelerator_handler_win.cc b/views/focus/accelerator_handler_win.cc
index ce6cecd..b5e4c22 100644
--- a/views/focus/accelerator_handler_win.cc
+++ b/views/focus/accelerator_handler_win.cc
@@ -24,7 +24,7 @@ bool AcceleratorHandler::Dispatch(const MSG& msg) {
switch (msg.message) {
case WM_KEYDOWN:
case WM_SYSKEYDOWN: {
- KeyEvent event(Event::ET_KEY_PRESSED,
+ KeyEvent event(ui::ET_KEY_PRESSED,
ui::KeyboardCodeForWindowsKeyCode(msg.wParam),
KeyEvent::GetKeyStateFlags(),
msg.lParam & 0xFFFF,
diff --git a/views/focus/focus_manager.cc b/views/focus/focus_manager.cc
index d217e63..5e5b2f4 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.GetKeyCode();
+ ui::KeyboardCode key_code = event.key_code();
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.GetKeyCode(),
+ Accelerator accelerator(event.key_code(),
event.IsShiftDown(),
event.IsControlDown(),
event.IsAltDown());
@@ -509,8 +509,7 @@ AcceleratorTarget* FocusManager::GetCurrentTargetForAccelerator(
// static
bool FocusManager::IsTabTraversalKeyEvent(const KeyEvent& key_event) {
- return key_event.GetKeyCode() == ui::VKEY_TAB &&
- !key_event.IsControlDown();
+ return key_event.key_code() == 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 bd21c16..457ed09 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.GetKeyCode());
+ keys_pressed_.push_back(e.key_code());
return true;
}
virtual bool OnKeyReleased(const KeyEvent& e) {
- keys_released_.push_back(e.GetKeyCode());
+ keys_released_.push_back(e.key_code());
return true;
}
diff --git a/views/native_types.h b/views/native_types.h
new file mode 100644
index 0000000..abea52e
--- /dev/null
+++ b/views/native_types.h
@@ -0,0 +1,28 @@
+// 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/touchui/gesture_manager.cc b/views/touchui/gesture_manager.cc
index 46ee0da..bc4fdd5 100644
--- a/views/touchui/gesture_manager.cc
+++ b/views/touchui/gesture_manager.cc
@@ -30,25 +30,25 @@ bool GestureManager::ProcessTouchEventForGesture(const TouchEvent& event,
// appear in a subsequent CL. This interim version permits verifying that the
// event distribution code works by turning all touch inputs into
// mouse approximations.
- if (event.GetType() == Event::ET_TOUCH_PRESSED) {
+ if (event.GetType() == ui::ET_TOUCH_PRESSED) {
DVLOG(1) << "GestureManager::ProcessTouchEventForGesture: TouchPressed";
- MouseEvent mouse_event(Event::ET_MOUSE_PRESSED, event.x(), event.y(),
+ MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, event.x(), event.y(),
event.GetFlags());
source->OnMousePressed(mouse_event);
return true;
}
- if (event.GetType() == Event::ET_TOUCH_RELEASED) {
+ if (event.GetType() == ui::ET_TOUCH_RELEASED) {
DVLOG(1) << "GestureManager::ProcessTouchEventForGesture: TouchReleased";
- MouseEvent mouse_event(Event::ET_MOUSE_RELEASED, event.x(), event.y(),
+ MouseEvent mouse_event(ui::ET_MOUSE_RELEASED, event.x(), event.y(),
event.GetFlags());
source->OnMouseReleased(mouse_event, false);
return true;
}
- if (event.GetType() == Event::ET_TOUCH_MOVED) {
+ if (event.GetType() == ui::ET_TOUCH_MOVED) {
DVLOG(1) << "GestureManager::ProcessTouchEventForGesture: TouchMotion";
- MouseEvent mouse_event(Event::ET_MOUSE_DRAGGED, event.x(), event.y(),
+ MouseEvent mouse_event(ui::ET_MOUSE_DRAGGED, event.x(), event.y(),
event.GetFlags());
source->OnMouseDragged(mouse_event);
return true;
diff --git a/views/view.cc b/views/view.cc
index f63f08f..d4ff9b1 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -672,7 +672,7 @@ View* View::GetViewForPoint(const gfx::Point& point) {
return this;
}
-gfx::NativeCursor View::GetCursorForPoint(Event::EventType event_type,
+gfx::NativeCursor View::GetCursorForPoint(ui::EventType event_type,
const gfx::Point& p) {
return NULL;
}
diff --git a/views/view.h b/views/view.h
index 7205b4f32..f8f331a 100644
--- a/views/view.h
+++ b/views/view.h
@@ -570,7 +570,7 @@ class View : public AcceleratorTarget {
// lifetime of the returned object, though that lifetime may vary from
// platform to platform. On Windows, the cursor is a shared resource but in
// Gtk, the framework destroys the returned cursor after setting it.
- virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type,
+ virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type,
const gfx::Point& p);
// Convenience to test whether a point is within this view's bounds
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index d2dc693..bee547d 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.GetType();
+ last_mouse_event_type_ = event.type();
location_.SetPoint(event.x(), event.y());
return true;
}
bool TestView::OnMouseDragged(const MouseEvent& event) {
- last_mouse_event_type_ = event.GetType();
+ last_mouse_event_type_ = event.type();
location_.SetPoint(event.x(), event.y());
return true;
}
void TestView::OnMouseReleased(const MouseEvent& event, bool canceled) {
- last_mouse_event_type_ = event.GetType();
+ last_mouse_event_type_ = event.type();
location_.SetPoint(event.x(), event.y());
}
@@ -364,12 +364,12 @@ TEST_F(ViewTest, MouseEvent) {
v1->Reset();
v2->Reset();
- MouseEvent pressed(Event::ET_MOUSE_PRESSED,
+ MouseEvent pressed(ui::ET_MOUSE_PRESSED,
110,
120,
- Event::EF_LEFT_BUTTON_DOWN);
+ ui::EF_LEFT_BUTTON_DOWN);
root->OnMousePressed(pressed);
- EXPECT_EQ(v2->last_mouse_event_type_, Event::ET_MOUSE_PRESSED);
+ EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_PRESSED);
EXPECT_EQ(v2->location_.x(), 10);
EXPECT_EQ(v2->location_.y(), 20);
// Make sure v1 did not receive the event
@@ -378,12 +378,12 @@ TEST_F(ViewTest, MouseEvent) {
// Drag event out of bounds. Should still go to v2
v1->Reset();
v2->Reset();
- MouseEvent dragged(Event::ET_MOUSE_DRAGGED,
+ MouseEvent dragged(ui::ET_MOUSE_DRAGGED,
50,
40,
- Event::EF_LEFT_BUTTON_DOWN);
+ ui::EF_LEFT_BUTTON_DOWN);
root->OnMouseDragged(dragged);
- EXPECT_EQ(v2->last_mouse_event_type_, Event::ET_MOUSE_DRAGGED);
+ EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_DRAGGED);
EXPECT_EQ(v2->location_.x(), -50);
EXPECT_EQ(v2->location_.y(), -60);
// Make sure v1 did not receive the event
@@ -392,9 +392,9 @@ TEST_F(ViewTest, MouseEvent) {
// Releasted event out of bounds. Should still go to v2
v1->Reset();
v2->Reset();
- MouseEvent released(Event::ET_MOUSE_RELEASED, 0, 0, 0);
+ MouseEvent released(ui::ET_MOUSE_RELEASED, 0, 0, 0);
root->OnMouseDragged(released);
- EXPECT_EQ(v2->last_mouse_event_type_, Event::ET_MOUSE_RELEASED);
+ EXPECT_EQ(v2->last_mouse_event_type_, ui::ET_MOUSE_RELEASED);
EXPECT_EQ(v2->location_.x(), -100);
EXPECT_EQ(v2->location_.y(), -100);
// Make sure v1 did not receive the event
@@ -429,12 +429,12 @@ View::TouchStatus TestView::OnTouchEvent(const TouchEvent& event) {
last_touch_event_type_ = event.GetType();
location_.SetPoint(event.x(), event.y());
if (!in_touch_sequence_) {
- if (event.GetType() == Event::ET_TOUCH_PRESSED) {
+ if (event.GetType() == ui::ET_TOUCH_PRESSED) {
in_touch_sequence_ = true;
return TOUCH_STATUS_START;
}
} else {
- if (event.GetType() == Event::ET_TOUCH_RELEASED) {
+ if (event.GetType() == ui::ET_TOUCH_RELEASED) {
in_touch_sequence_ = false;
return TOUCH_STATUS_END;
}
@@ -474,7 +474,7 @@ TEST_F(ViewTest, TouchEvent) {
v2->Reset();
gm->Reset();
- TouchEvent unhandled(Event::ET_TOUCH_MOVED,
+ TouchEvent unhandled(ui::ET_TOUCH_MOVED,
400,
400,
0, /* no flags */
@@ -485,7 +485,7 @@ TEST_F(ViewTest, TouchEvent) {
EXPECT_EQ(v2->last_touch_event_type_, 0);
EXPECT_EQ(gm->previously_handled_flag_, false);
- EXPECT_EQ(gm->last_touch_event_, Event::ET_TOUCH_MOVED);
+ EXPECT_EQ(gm->last_touch_event_, ui::ET_TOUCH_MOVED);
EXPECT_EQ(gm->last_view_, root);
EXPECT_EQ(gm->dispatched_synthetic_event_, true);
@@ -494,7 +494,7 @@ TEST_F(ViewTest, TouchEvent) {
v2->Reset();
gm->Reset();
- TouchEvent pressed(Event::ET_TOUCH_PRESSED,
+ TouchEvent pressed(ui::ET_TOUCH_PRESSED,
110,
120,
0, /* no flags */
@@ -502,7 +502,7 @@ TEST_F(ViewTest, TouchEvent) {
v2->last_touch_event_was_handled_ = true;
root->OnTouchEvent(pressed);
- EXPECT_EQ(v2->last_touch_event_type_, Event::ET_TOUCH_PRESSED);
+ EXPECT_EQ(v2->last_touch_event_type_, ui::ET_TOUCH_PRESSED);
EXPECT_EQ(v2->location_.x(), 10);
EXPECT_EQ(v2->location_.y(), 20);
// Make sure v1 did not receive the event
@@ -516,13 +516,13 @@ TEST_F(ViewTest, TouchEvent) {
// Drag event out of bounds. Should still go to v2
v1->Reset();
v2->Reset();
- TouchEvent dragged(Event::ET_TOUCH_MOVED,
+ TouchEvent dragged(ui::ET_TOUCH_MOVED,
50,
40,
0, /* no flags */
0 /* first finger touch */);
root->OnTouchEvent(dragged);
- EXPECT_EQ(v2->last_touch_event_type_, Event::ET_TOUCH_MOVED);
+ EXPECT_EQ(v2->last_touch_event_type_, ui::ET_TOUCH_MOVED);
EXPECT_EQ(v2->location_.x(), -50);
EXPECT_EQ(v2->location_.y(), -60);
// Make sure v1 did not receive the event
@@ -535,10 +535,10 @@ TEST_F(ViewTest, TouchEvent) {
// Released event out of bounds. Should still go to v2
v1->Reset();
v2->Reset();
- TouchEvent released(Event::ET_TOUCH_RELEASED, 0, 0, 0, 0 /* first finger */);
+ TouchEvent released(ui::ET_TOUCH_RELEASED, 0, 0, 0, 0 /* first finger */);
v2->last_touch_event_was_handled_ = true;
root->OnTouchEvent(released);
- EXPECT_EQ(v2->last_touch_event_type_, Event::ET_TOUCH_RELEASED);
+ EXPECT_EQ(v2->last_touch_event_type_, ui::ET_TOUCH_RELEASED);
EXPECT_EQ(v2->location_.x(), -100);
EXPECT_EQ(v2->location_.y(), -100);
// Make sure v1 did not receive the event
@@ -1270,7 +1270,7 @@ class DefaultButtonTest : public ViewTest {
}
void SimularePressingEnterAndCheckDefaultButton(ButtonID button_id) {
- KeyEvent event(Event::ET_KEY_PRESSED, ui::VKEY_RETURN, 0, 0, 0);
+ KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, 0, 0, 0);
focus_manager_->OnKeyEvent(event);
switch (button_id) {
case OK:
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index 6010d99..83e33e8 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.GetFlags() & MouseEvent::EF_IS_NON_CLIENT) &&
- !(e.GetFlags() & MouseEvent::EF_IS_DOUBLE_CLICK)) {
+ if ((e.flags() & ui::EF_IS_NON_CLIENT) &&
+ !(e.flags() & ui::EF_IS_DOUBLE_CLICK)) {
last_click_handler_ = NULL;
return false;
}
@@ -424,8 +424,8 @@ 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.GetFlags() &
- ~MouseEvent::EF_IS_DOUBLE_CLICK);
+ mouse_pressed_event.set_flags(e.flags() &
+ ~ui::EF_IS_DOUBLE_CLICK);
drag_info.Reset();
bool handled = mouse_pressed_handler_->ProcessMousePressed(
@@ -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.GetFlags() & MouseEvent::EF_IS_DOUBLE_CLICK)
+ if (last_click_handler_ && e.flags() & ui::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.GetType(), l);
+ cursor = v->GetCursorForPoint(e.type(), l);
}
SetActiveCursor(cursor);
}
@@ -521,7 +521,7 @@ bool RootView::OnMouseDragged(const MouseEvent& e) {
gfx::Point p;
ConvertPointToMouseHandler(e.location(), &p);
- MouseEvent mouse_event(e.GetType(), p.x(), p.y(), e.GetFlags());
+ MouseEvent mouse_event(e.type(), p.x(), p.y(), e.flags());
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.GetType(), p.x(), p.y(), e.GetFlags());
+ MouseEvent mouse_released(e.type(), p.x(), p.y(), e.flags());
// 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_;
@@ -555,20 +555,20 @@ void RootView::OnMouseMoved(const MouseEvent& e) {
if (v && v != this) {
if (v != mouse_move_handler_) {
if (mouse_move_handler_ != NULL) {
- MouseEvent exited_event(Event::ET_MOUSE_EXITED, 0, 0, 0);
+ MouseEvent exited_event(ui::ET_MOUSE_EXITED, 0, 0, 0);
mouse_move_handler_->OnMouseExited(exited_event);
}
mouse_move_handler_ = v;
- MouseEvent entered_event(Event::ET_MOUSE_ENTERED,
+ MouseEvent entered_event(ui::ET_MOUSE_ENTERED,
this,
mouse_move_handler_,
e.location(),
0);
mouse_move_handler_->OnMouseEntered(entered_event);
}
- MouseEvent moved_event(Event::ET_MOUSE_MOVED,
+ MouseEvent moved_event(ui::ET_MOUSE_MOVED,
this,
mouse_move_handler_,
e.location(),
@@ -576,10 +576,10 @@ void RootView::OnMouseMoved(const MouseEvent& e) {
mouse_move_handler_->OnMouseMoved(moved_event);
gfx::NativeCursor cursor = mouse_move_handler_->GetCursorForPoint(
- moved_event.GetType(), moved_event.location());
+ moved_event.type(), moved_event.location());
SetActiveCursor(cursor);
} else if (mouse_move_handler_ != NULL) {
- MouseEvent exited_event(Event::ET_MOUSE_EXITED, 0, 0, 0);
+ MouseEvent exited_event(ui::ET_MOUSE_EXITED, 0, 0, 0);
mouse_move_handler_->OnMouseExited(exited_event);
SetActiveCursor(NULL);
}
@@ -587,7 +587,7 @@ void RootView::OnMouseMoved(const MouseEvent& e) {
void RootView::ProcessOnMouseExited() {
if (mouse_move_handler_ != NULL) {
- MouseEvent exited_event(Event::ET_MOUSE_EXITED, 0, 0, 0);
+ MouseEvent exited_event(ui::ET_MOUSE_EXITED, 0, 0, 0);
mouse_move_handler_->OnMouseExited(exited_event);
mouse_move_handler_ = NULL;
}
@@ -602,7 +602,7 @@ void RootView::SetMouseHandler(View *new_mh) {
void RootView::ProcessMouseDragCanceled() {
if (mouse_pressed_handler_) {
// Synthesize a release event.
- MouseEvent release_event(Event::ET_MOUSE_RELEASED, last_mouse_event_x_,
+ MouseEvent release_event(ui::ET_MOUSE_RELEASED, last_mouse_event_x_,
last_mouse_event_y_, last_mouse_event_flags_);
OnMouseReleased(release_event, true);
}
@@ -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.GetKeyCode() == ui::VKEY_APPS) ||
- (event.GetKeyCode() == ui::VKEY_F10 && event.IsShiftDown()))) {
+ if (v && v->IsEnabled() && ((event.key_code() == ui::VKEY_APPS) ||
+ (event.key_code() == ui::VKEY_F10 && event.IsShiftDown()))) {
v->ShowContextMenu(v->GetKeyboardContextMenuLocation(), false);
return true;
}
for (; v && v != this && !consumed; v = v->parent()) {
- consumed = (event.GetType() == Event::ET_KEY_PRESSED) ?
+ consumed = (event.type() == ui::ET_KEY_PRESSED) ?
v->OnKeyPressed(event) : v->OnKeyReleased(event);
}
if (!consumed && default_keyboard_handler_) {
- consumed = (event.GetType() == Event::ET_KEY_PRESSED) ?
+ consumed = (event.type() == ui::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.GetFlags();
+ last_mouse_event_flags_ = e.flags();
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 730d6f7..d40ec45 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.GetKeyCode();
+ int key_code = key.key_code();
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.GetFlags() & ~Event::EF_ALT_DOWN) == 0) {
+ (key.flags() & ~ui::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);
@@ -916,20 +916,20 @@ int WidgetGtk::GetFlagsForEventButton(const GdkEventButton& event) {
int flags = Event::GetFlagsFromGdkState(event.state);
switch (event.button) {
case 1:
- flags |= Event::EF_LEFT_BUTTON_DOWN;
+ flags |= ui::EF_LEFT_BUTTON_DOWN;
break;
case 2:
- flags |= Event::EF_MIDDLE_BUTTON_DOWN;
+ flags |= ui::EF_MIDDLE_BUTTON_DOWN;
break;
case 3:
- flags |= Event::EF_RIGHT_BUTTON_DOWN;
+ flags |= ui::EF_RIGHT_BUTTON_DOWN;
break;
default:
// We only deal with 1-3.
break;
}
if (event.type == GDK_2BUTTON_PRESS)
- flags |= MouseEvent::EF_IS_DOUBLE_CLICK;
+ flags |= ui::EF_IS_DOUBLE_CLICK;
return flags;
}
@@ -1078,10 +1078,10 @@ gboolean WidgetGtk::OnEnterNotify(GtkWidget* widget, GdkEventCrossing* event) {
// modifiers is set. Unset it as we're compensating for the leave generated
// when you press a button.
int flags = (Event::GetFlagsFromGdkState(event->state) &
- ~(Event::EF_LEFT_BUTTON_DOWN |
- Event::EF_MIDDLE_BUTTON_DOWN |
- Event::EF_RIGHT_BUTTON_DOWN));
- MouseEvent mouse_move(Event::ET_MOUSE_MOVED, x, y, flags);
+ ~(ui::EF_LEFT_BUTTON_DOWN |
+ ui::EF_MIDDLE_BUTTON_DOWN |
+ ui::EF_RIGHT_BUTTON_DOWN));
+ MouseEvent mouse_move(ui::ET_MOUSE_MOVED, x, y, flags);
root_view_->OnMouseMoved(mouse_move);
}
@@ -1102,7 +1102,7 @@ gboolean WidgetGtk::OnMotionNotify(GtkWidget* widget, GdkEventMotion* event) {
if (has_capture_ && is_mouse_down_) {
last_mouse_event_was_move_ = false;
int flags = Event::GetFlagsFromGdkState(event->state);
- MouseEvent mouse_drag(Event::ET_MOUSE_DRAGGED, x, y, flags);
+ MouseEvent mouse_drag(ui::ET_MOUSE_DRAGGED, x, y, flags);
root_view_->OnMouseDragged(mouse_drag);
return true;
}
@@ -1116,7 +1116,7 @@ gboolean WidgetGtk::OnMotionNotify(GtkWidget* widget, GdkEventMotion* event) {
last_mouse_move_y_ = screen_loc.y();
last_mouse_event_was_move_ = true;
int flags = Event::GetFlagsFromGdkState(event->state);
- MouseEvent mouse_move(Event::ET_MOUSE_MOVED, x, y, flags);
+ MouseEvent mouse_move(ui::ET_MOUSE_MOVED, x, y, flags);
root_view_->OnMouseMoved(mouse_move);
return true;
}
@@ -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.GetKeyCode() != ui::VKEY_MENU || event->type != GDK_KEY_RELEASE)
+ if (key.key_code() != ui::VKEY_MENU || event->type != GDK_KEY_RELEASE)
should_handle_menu_key_release_ = false;
bool handled = false;
@@ -1308,7 +1308,7 @@ bool WidgetGtk::ProcessMousePressed(GdkEventButton* event) {
int y = 0;
GetContainedWidgetEventCoordinates(event, &x, &y);
last_mouse_event_was_move_ = false;
- MouseEvent mouse_pressed(Event::ET_MOUSE_PRESSED, x, y,
+ MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, x, y,
GetFlagsForEventButton(*event));
if (root_view_->OnMousePressed(mouse_pressed)) {
@@ -1327,7 +1327,7 @@ void WidgetGtk::ProcessMouseReleased(GdkEventButton* event) {
GetContainedWidgetEventCoordinates(event, &x, &y);
last_mouse_event_was_move_ = false;
- MouseEvent mouse_up(Event::ET_MOUSE_RELEASED, x, y,
+ MouseEvent mouse_up(ui::ET_MOUSE_RELEASED, x, y,
GetFlagsForEventButton(*event));
// Release the capture first, that way we don't get confused if
// OnMouseReleased blocks.
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index d4e4267..bfa63b7 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -689,7 +689,7 @@ void WidgetWin::OnInitMenuPopup(HMENU menu,
}
void WidgetWin::OnKeyDown(TCHAR c, UINT rep_cnt, UINT flags) {
- KeyEvent event(Event::ET_KEY_PRESSED, ui::KeyboardCodeForWindowsKeyCode(c),
+ KeyEvent event(ui::ET_KEY_PRESSED, ui::KeyboardCodeForWindowsKeyCode(c),
KeyEvent::GetKeyStateFlags(), rep_cnt, flags,
WM_KEYDOWN);
RootView* root_view = GetFocusedViewRootView();
@@ -700,7 +700,7 @@ void WidgetWin::OnKeyDown(TCHAR c, UINT rep_cnt, UINT flags) {
}
void WidgetWin::OnKeyUp(TCHAR c, UINT rep_cnt, UINT flags) {
- KeyEvent event(Event::ET_KEY_RELEASED, ui::KeyboardCodeForWindowsKeyCode(c),
+ KeyEvent event(ui::ET_KEY_RELEASED, ui::KeyboardCodeForWindowsKeyCode(c),
KeyEvent::GetKeyStateFlags(), rep_cnt, flags,
WM_KEYUP);
RootView* root_view = GetFocusedViewRootView();
@@ -1020,11 +1020,11 @@ bool WidgetWin::ProcessMousePressed(const CPoint& point,
gfx::Point converted_point(point);
if (non_client)
View::ConvertPointToView(NULL, root_view_.get(), &converted_point);
- MouseEvent mouse_pressed(Event::ET_MOUSE_PRESSED,
+ MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED,
converted_point.x(),
converted_point.y(),
- (dbl_click ? MouseEvent::EF_IS_DOUBLE_CLICK : 0) |
- (non_client ? MouseEvent::EF_IS_NON_CLIENT : 0) |
+ (dbl_click ? ui::EF_IS_DOUBLE_CLICK : 0) |
+ (non_client ? ui::EF_IS_NON_CLIENT : 0) |
Event::ConvertWindowsFlags(flags));
if (root_view_->OnMousePressed(mouse_pressed)) {
is_mouse_down_ = true;
@@ -1039,7 +1039,7 @@ bool WidgetWin::ProcessMousePressed(const CPoint& point,
void WidgetWin::ProcessMouseDragged(const CPoint& point, UINT flags) {
last_mouse_event_was_move_ = false;
- MouseEvent mouse_drag(Event::ET_MOUSE_DRAGGED,
+ MouseEvent mouse_drag(ui::ET_MOUSE_DRAGGED,
point.x,
point.y,
Event::ConvertWindowsFlags(flags));
@@ -1048,7 +1048,7 @@ void WidgetWin::ProcessMouseDragged(const CPoint& point, UINT flags) {
void WidgetWin::ProcessMouseReleased(const CPoint& point, UINT flags) {
last_mouse_event_was_move_ = false;
- MouseEvent mouse_up(Event::ET_MOUSE_RELEASED,
+ MouseEvent mouse_up(ui::ET_MOUSE_RELEASED,
point.x,
point.y,
Event::ConvertWindowsFlags(flags));
@@ -1082,7 +1082,7 @@ void WidgetWin::ProcessMouseMoved(const CPoint &point, UINT flags,
last_mouse_move_x_ = screen_loc.x();
last_mouse_move_y_ = screen_loc.y();
last_mouse_event_was_move_ = true;
- MouseEvent mouse_move(Event::ET_MOUSE_MOVED,
+ MouseEvent mouse_move(ui::ET_MOUSE_MOVED,
point.x,
point.y,
Event::ConvertWindowsFlags(flags));
diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc
index 13a9764..e933e98 100644
--- a/views/window/window_gtk.cc
+++ b/views/window/window_gtk.cc
@@ -277,7 +277,7 @@ gboolean WindowGtk::OnButtonPress(GtkWidget* widget, GdkEventButton* event) {
non_client_view_->NonClientHitTest(gfx::Point(x, y));
switch (hittest_code) {
case HTCAPTION: {
- MouseEvent mouse_pressed(Event::ET_MOUSE_PRESSED, event->x, event->y,
+ MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, event->x, event->y,
WidgetGtk::GetFlagsForEventButton(*event));
// Start dragging if the mouse event is a single click and *not* a right
// click. If it is a right click, then pass it through to