Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1181)

Unified Diff: views/events/event.h

Issue 6480001: Migrate Event API methods to Google Style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: views/events/event.h
===================================================================
--- views/events/event.h (revision 74326)
+++ views/events/event.h (working copy)
@@ -10,6 +10,7 @@
#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;
@@ -76,44 +77,19 @@
EF_COMMAND_DOWN = 1 << 7, // Only useful on OSX
};
- // Return the event type
- EventType GetType() const {
- return type_;
- }
+ 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 time stamp.
- const base::Time& GetTimeStamp() const {
- return time_stamp_;
- }
+ // 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 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;
- }
-
bool IsMouseEvent() const {
return type_ == ET_MOUSE_PRESSED ||
type_ == ET_MOUSE_DRAGGED ||
@@ -149,14 +125,16 @@
Event(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&);
+ NativeEvent native_event_;
EventType type_;
base::Time time_stamp_;
int flags_;
@@ -182,21 +160,10 @@
// 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();
- }
+ int x() const { return location_.x(); }
+ int y() const { return location_.y(); }
+ const gfx::Point& location() const { return location_; }
- // Returns the Y location.
- int y() const {
- return location_.y();
- }
-
- // Returns the location.
- const gfx::Point& location() const {
- return location_;
- }
-
private:
gfx::Point location_;
};
@@ -242,30 +209,30 @@
// 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() & EF_LEFT_BUTTON_DOWN) &&
+ !(flags() & (EF_MIDDLE_BUTTON_DOWN | EF_RIGHT_BUTTON_DOWN));
}
bool IsLeftMouseButton() const {
- return (GetFlags() & EF_LEFT_BUTTON_DOWN) != 0;
+ return (flags() & 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() & EF_MIDDLE_BUTTON_DOWN) &&
+ !(flags() & (EF_LEFT_BUTTON_DOWN | EF_RIGHT_BUTTON_DOWN));
}
bool IsMiddleMouseButton() const {
- return (GetFlags() & EF_MIDDLE_BUTTON_DOWN) != 0;
+ return (flags() & 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() & EF_RIGHT_BUTTON_DOWN) &&
+ !(flags() & (EF_LEFT_BUTTON_DOWN | EF_MIDDLE_BUTTON_DOWN));
}
bool IsRightMouseButton() const {
- return (GetFlags() & EF_RIGHT_BUTTON_DOWN) != 0;
+ return (flags() & EF_RIGHT_BUTTON_DOWN) != 0;
}
private:
@@ -306,10 +273,7 @@
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
@@ -355,25 +319,15 @@
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();
@@ -412,9 +366,7 @@
explicit MouseWheelEvent(XEvent* xev);
#endif
- int GetOffset() const {
- return offset_;
- }
+ int offset() const { return offset_; }
private:
int offset_;
@@ -441,14 +393,14 @@
source_operations_(source_operations) {
}
- // Data associated with the drag/drop session.
- const OSExchangeData& GetData() const { return data_; }
+ const OSExchangeData& data() const { return data_; }
+ int source_operations() const { return source_operations_; }
- // Bitmask of supported ui::DragDropTypes::DragOperation by the source.
- int GetSourceOperations() 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);

Powered by Google App Engine
This is Rietveld 408576698