Pepper_56_C++_interfaces
Pepper_56_C++_interfaces
 All Classes Namespaces Files Functions Typedefs Enumerations Macros Groups
input_event.h
Go to the documentation of this file.
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef PPAPI_CPP_INPUT_EVENT_H_
6 #define PPAPI_CPP_INPUT_EVENT_H_
7 
8 #include <stdint.h>
9 
10 #include <string>
11 #include <vector>
12 
13 #include "ppapi/c/ppb_input_event.h"
14 #include "ppapi/cpp/resource.h"
15 #include "ppapi/cpp/touch_point.h"
16 
19 
20 namespace pp {
21 
22 class FloatPoint;
23 class InstanceHandle;
24 class Point;
25 class Var;
26 
48 class InputEvent : public Resource {
49  public:
51  InputEvent();
52 
58  explicit InputEvent(PP_Resource input_event_resource);
59 
60  ~InputEvent();
61 
67  PP_InputEvent_Type GetType() const;
68 
82  PP_TimeTicks GetTimeStamp() const;
83 
90  uint32_t GetModifiers() const;
91 };
92 
94 class MouseInputEvent : public InputEvent {
95  public:
98 
104  explicit MouseInputEvent(const InputEvent& event);
105 
128  // TODO(brettw) figure out exactly what this means.
131  MouseInputEvent(const InstanceHandle& instance,
132  PP_InputEvent_Type type,
133  PP_TimeTicks time_stamp,
134  uint32_t modifiers,
135  PP_InputEvent_MouseButton mouse_button,
136  const Point& mouse_position,
137  int32_t click_count,
138  const Point& mouse_movement);
139 
145  PP_InputEvent_MouseButton GetButton() const;
146 
154  Point GetPosition() const;
155 
156  // TODO(brettw) figure out exactly what this means.
157  int32_t GetClickCount() const;
158 
166  Point GetMovement() const;
167 };
168 
169 class WheelInputEvent : public InputEvent {
170  public:
172  WheelInputEvent();
173 
180  explicit WheelInputEvent(const InputEvent& event);
181 
200  WheelInputEvent(const InstanceHandle& instance,
201  PP_TimeTicks time_stamp,
202  uint32_t modifiers,
203  const FloatPoint& wheel_delta,
204  const FloatPoint& wheel_ticks,
205  bool scroll_by_page);
206 
226  FloatPoint GetDelta() const;
227 
245  FloatPoint GetTicks() const;
246 
252  bool GetScrollByPage() const;
253 };
254 
256  public:
259 
265  explicit KeyboardInputEvent(const InputEvent& event);
266 
286  KeyboardInputEvent(const InstanceHandle& instance,
287  PP_InputEvent_Type type,
288  PP_TimeTicks time_stamp,
289  uint32_t modifiers,
290  uint32_t key_code,
291  const Var& character_text);
292 
316  KeyboardInputEvent(const InstanceHandle& instance,
317  PP_InputEvent_Type type,
318  PP_TimeTicks time_stamp,
319  uint32_t modifiers,
320  uint32_t key_code,
321  const Var& character_text,
322  const Var& code);
323 
326  uint32_t GetKeyCode() const;
327 
333  Var GetCharacterText() const;
334 
336  //
339  Var GetCode() const;
340 };
341 
342 class TouchInputEvent : public InputEvent {
343  public:
345  TouchInputEvent();
346 
350  explicit TouchInputEvent(const InputEvent& event);
351 
364  TouchInputEvent(const InstanceHandle& instance,
365  PP_InputEvent_Type type,
366  PP_TimeTicks time_stamp,
367  uint32_t modifiers);
368 
370  void AddTouchPoint(PP_TouchListType list, PP_TouchPoint point);
371 
373  uint32_t GetTouchCount(PP_TouchListType list) const;
374 
377  TouchPoint GetTouchByIndex(PP_TouchListType list, uint32_t index) const;
378 
382  TouchPoint GetTouchById(PP_TouchListType list, uint32_t id) const;
383 };
384 
385 class IMEInputEvent : public InputEvent {
386  public:
388  IMEInputEvent();
389 
395  explicit IMEInputEvent(const InputEvent& event);
396 
417  IMEInputEvent(const InstanceHandle& instance,
418  PP_InputEvent_Type type,
419  PP_TimeTicks time_stamp,
420  const Var& text,
421  const std::vector<uint32_t>& segment_offsets,
422  int32_t target_segment,
423  const std::pair<uint32_t, uint32_t>& selection);
424 
429  Var GetText() const;
430 
435  uint32_t GetSegmentNumber() const;
436 
453  uint32_t GetSegmentOffset(uint32_t index) const;
454 
460  int32_t GetTargetSegment() const;
461 
467  void GetSelection(uint32_t* start, uint32_t* end) const;
468 };
469 } // namespace pp
470 
471 #endif // PPAPI_CPP_INPUT_EVENT_H_
bool GetScrollByPage() const
uint32_t GetSegmentNumber() const
TouchPoint GetTouchByIndex(PP_TouchListType list, uint32_t index) const
void AddTouchPoint(PP_TouchListType list, PP_TouchPoint point)
Adds the touch-point to the specified TouchList.
Definition: input_event.h:169
uint32_t GetModifiers() const
A 2 dimensional point with 0,0 being the upper-left starting coordinate.
Definition: point.h:18
KeyboardInputEvent()
Constructs an is_null() keyboard input event object.
IMEInputEvent()
Constructs an is_null() IME input event object.
Definition: input_event.h:342
Var GetCharacterText() const
PP_TimeTicks GetTimeStamp() const
Var GetCode() const
Returns the DOM |code| for the keyboard event.
Point GetPosition() const
uint32_t GetTouchCount(PP_TouchListType list) const
Var GetText() const
Definition: input_event.h:255
Definition: input_event.h:48
Definition: instance_handle.h:44
TouchPoint GetTouchById(PP_TouchListType list, uint32_t id) const
TouchInputEvent()
Constructs an is_null() touch input event object.
PP_InputEvent_MouseButton GetButton() const
uint32_t GetKeyCode() const
InputEvent()
Default constructor that creates an is_null() InputEvent object.
FloatPoint GetTicks() const
Definition: input_event.h:385
MouseInputEvent()
Constructs an is_null() mouse input event object.
Definition: point.h:157
WheelInputEvent()
Constructs an is_null() wheel input event object.
Wrapper class for PP_TouchPoint.
Definition: touch_point.h:17
A generic type used for passing data types between the module and the page.
Definition: var.h:23
void GetSelection(uint32_t *start, uint32_t *end) const
FloatPoint GetDelta() const
A reference counted module resource.
Definition: resource.h:20
PP_InputEvent_Type GetType() const
Point GetMovement() const
int32_t GetTargetSegment() const
uint32_t GetSegmentOffset(uint32_t index) const
This class handles mouse events.
Definition: input_event.h:94