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/events | |
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/events')
-rw-r--r-- | views/events/event.h | 126 |
1 files changed, 87 insertions, 39 deletions
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); |