15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef PPAPI_CPP_INPUT_EVENT_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PPAPI_CPP_INPUT_EVENT_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 9a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include <vector> 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_input_event.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/resource.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/touch_point.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// @file 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// This file defines the API used to handle mouse and keyboard input events. 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace pp { 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class FloatPoint; 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class InstanceHandle; 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Point; 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Var; 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// This class represents an input event resource. Normally you will get passed 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// this object through the HandleInputEvent() function on the 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// <code>Instance</code> object. 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// Typically you would check the type of the event and then create the 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// appropriate event-specific object to query the properties. 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// <strong>Example:</strong> 33c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)/// @code 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// bool MyInstance::HandleInputEvent(const pp::InputEvent& event) { 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// switch (event.GetType()) { 37eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch/// case PP_INPUTEVENT_TYPE_MOUSEDOWN { 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// pp::MouseInputEvent mouse_event(event); 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// return HandleMouseDown(mouse_event.GetMousePosition()); 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// } 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// default: 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// return false; 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// } 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// 45c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)/// @endcode 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class InputEvent : public Resource { 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Default constructor that creates an is_null() InputEvent object. 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) InputEvent(); 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// This constructor constructs an input event from the provided input event 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// resource ID. The InputEvent object will be is_null() if the given 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// resource is not a valid input event. 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] input_event_resource A input event resource ID. 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) explicit InputEvent(PP_Resource input_event_resource); 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ~InputEvent(); 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// GetType() returns the type of input event for this input event 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// object. 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @return A <code>PP_InputEvent_Type</code> if successful, 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// PP_INPUTEVENT_TYPE_UNDEFINED if the resource is invalid. 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_InputEvent_Type GetType() const; 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// GetTimeStamp() returns the time that the event was generated. The time 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// will be before the current time since processing and dispatching the 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// event has some overhead. Use this value to compare the times the user 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// generated two events without being sensitive to variable processing time. 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// The return value is in time ticks, which is a monotonically increasing 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// clock not related to the wall clock time. It will not change if the user 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// changes their clock or daylight savings time starts, so can be reliably 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// used to compare events. This means, however, that you can't correlate 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// event times to a particular time of day on the system clock. 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @return A <code>PP_TimeTicks</code> containing the time the event was 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// generated. 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_TimeTicks GetTimeStamp() const; 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// GetModifiers() returns a bitfield indicating which modifiers were down 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// at the time of the event. This is a combination of the flags in the 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// <code>PP_InputEvent_Modifier</code> enum. 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @return The modifiers associated with the event, or 0 if the given 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// resource is not a valid event resource. 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) uint32_t GetModifiers() const; 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/// This class handles mouse events. 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class MouseInputEvent : public InputEvent { 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Constructs an is_null() mouse input event object. 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) MouseInputEvent(); 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// This constructor constructs a mouse input event object from the provided 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// generic input event. If the given event is itself is_null() or is not 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// a mouse input event, the mouse object will be is_null(). 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param event An <code>InputEvent</code>. 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) explicit MouseInputEvent(const InputEvent& event); 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// This constructor manually constructs a mouse event from the provided 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// parameters. 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 107c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) /// @param[in] instance The instance for which this event occurred. 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// input event. 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time 113c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) /// when the event occurred. 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] modifiers A bit field combination of the 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// <code>PP_InputEvent_Modifier</code> flags. 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] mouse_button The button that changed for mouse down or up 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// events. This value will be <code>PP_EVENT_MOUSEBUTTON_NONE</code> for 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// mouse move, enter, and leave events. 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] mouse_position A <code>Point</code> containing the x and y 123c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) /// position of the mouse when the event occurred. 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] click_count 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(brettw) figure out exactly what this means. 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] mouse_movement The change in position of the mouse. 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) MouseInputEvent(const InstanceHandle& instance, 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_InputEvent_Type type, 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_TimeTicks time_stamp, 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) uint32_t modifiers, 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_InputEvent_MouseButton mouse_button, 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const Point& mouse_position, 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int32_t click_count, 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const Point& mouse_movement); 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// GetButton() returns the mouse position for a mouse input event. 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @return The mouse button associated with mouse down and up events. This 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// value will be PP_EVENT_MOUSEBUTTON_NONE for mouse move, enter, and leave 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// events, and for all non-mouse events. 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_InputEvent_MouseButton GetButton() const; 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// GetPosition() returns the pixel location of a mouse input event. When 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// the mouse is locked, it returns the last known mouse position just as 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// mouse lock was entered. 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @return The point associated with the mouse event, relative to the upper- 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// left of the instance receiving the event. These values can be negative for 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// mouse drags. The return value will be (0, 0) for non-mouse events. 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Point GetPosition() const; 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(brettw) figure out exactly what this means. 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int32_t GetClickCount() const; 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Returns the change in position of the mouse. When the mouse is locked, 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// although the mouse position doesn't actually change, this function 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// still provides movement information, which indicates what the change in 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// position would be had the mouse not been locked. 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @return The change in position of the mouse, relative to the previous 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// position. 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Point GetMovement() const; 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WheelInputEvent : public InputEvent { 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Constructs an is_null() wheel input event object. 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WheelInputEvent(); 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// This constructor constructs a wheel input event object from the 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// provided generic input event. If the given event is itself 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// is_null() or is not a wheel input event, the wheel object will be 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// is_null(). 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] event A generic input event. 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) explicit WheelInputEvent(const InputEvent& event); 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Constructs a wheel input even from the given parameters. 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 182c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) /// @param[in] instance The instance for which this event occurred. 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time 185c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) /// when the event occurred. 1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] modifiers A bit field combination of the 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// <code>PP_InputEvent_Modifier</code> flags. 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] wheel_delta The scroll wheel's horizontal and vertical scroll 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// amounts. 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] wheel_ticks The number of "clicks" of the scroll wheel that 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// have produced the event. 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] scroll_by_page When true, the user is requesting to scroll 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// by pages. When false, the user is requesting to scroll by lines. 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WheelInputEvent(const InstanceHandle& instance, 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_TimeTicks time_stamp, 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) uint32_t modifiers, 2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const FloatPoint& wheel_delta, 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const FloatPoint& wheel_ticks, 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool scroll_by_page); 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// GetDelta() returns the amount vertically and horizontally the user has 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// requested to scroll by with their mouse wheel. A scroll down or to the 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// right (where the content moves up or left) is represented as positive 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// values, and a scroll up or to the left (where the content moves down or 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// right) is represented as negative values. 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// This amount is system dependent and will take into account the user's 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// preferred scroll sensitivity and potentially also nonlinear acceleration 2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// based on the speed of the scrolling. 2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Devices will be of varying resolution. Some mice with large detents will 2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// only generate integer scroll amounts. But fractional values are also 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// possible, for example, on some trackpads and newer mice that don't have 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// "clicks". 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 220c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) /// @return The vertical and horizontal scroll values. The units are either in 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// pixels (when scroll_by_page is false) or pages (when scroll_by_page is 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// true). For example, y = -3 means scroll up 3 pixels when scroll_by_page 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// is false, and scroll up 3 pages when scroll_by_page is true. 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FloatPoint GetDelta() const; 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// GetTicks() returns the number of "clicks" of the scroll wheel 2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// that have produced the event. The value may have system-specific 2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// acceleration applied to it, depending on the device. The positive and 2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// negative meanings are the same as for GetDelta(). 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// If you are scrolling, you probably want to use the delta values. These 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// tick events can be useful if you aren't doing actual scrolling and don't 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// want or pixel values. An example may be cycling between different items in 2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// a game. 2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @return The number of "clicks" of the scroll wheel. You may receive 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// fractional values for the wheel ticks if the mouse wheel is high 2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// resolution or doesn't have "clicks". If your program wants discrete 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// events (as in the "picking items" example) you should accumulate 2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// fractional click values from multiple messages until the total value 2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// reaches positive or negative one. This should represent a similar amount 2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// of scrolling as for a mouse that has a discrete mouse wheel. 2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FloatPoint GetTicks() const; 2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// GetScrollByPage() indicates if the scroll delta x/y indicates pages or 2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// lines to scroll by. 2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @return true if the event is a wheel event and the user is scrolling 2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// by pages, false if not or if the resource is not a wheel event. 2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool GetScrollByPage() const; 2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class KeyboardInputEvent : public InputEvent { 2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Constructs an is_null() keyboard input event object. 2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) KeyboardInputEvent(); 2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Constructs a keyboard input event object from the provided generic input 2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// event. If the given event is itself is_null() or is not a keyboard input 2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// event, the keybaord object will be is_null(). 2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] event A generic input event. 2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) explicit KeyboardInputEvent(const InputEvent& event); 2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Constructs a keyboard input even from the given parameters. 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 267c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) /// @param[in] instance The instance for which this event occurred. 2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of 2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// input event. 2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time 273c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) /// when the event occurred. 2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] modifiers A bit field combination of the 2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// <code>PP_InputEvent_Modifier</code> flags. 2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] key_code This value reflects the DOM KeyboardEvent 2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// <code>keyCode</code> field. Chrome populates this with the Windows-style 2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Virtual Key code of the key. 2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] character_text This value represents the typed character as a 2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// UTF-8 string. 2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) KeyboardInputEvent(const InstanceHandle& instance, 2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_InputEvent_Type type, 2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_TimeTicks time_stamp, 2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) uint32_t modifiers, 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) uint32_t key_code, 2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const Var& character_text); 2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// Constructs a keyboard input even from the given parameters. 2925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// 2935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// @param[in] instance The instance for which this event occurred. 2945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// 2955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of 2965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// input event. 2975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// 2985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time 2995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// when the event occurred. 3005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// 3015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// @param[in] modifiers A bit field combination of the 3025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// <code>PP_InputEvent_Modifier</code> flags. 3035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// 3045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// @param[in] key_code This value reflects the DOM KeyboardEvent 3055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// <code>keyCode</code> field. Chrome populates this with the Windows-style 3065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// Virtual Key code of the key. 3075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// 3085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// @param[in] character_text This value represents the typed character as a 3095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// UTF-8 string. 3105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// 3115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// @param[in] code This value reflects the DOM KeyboardEvent 3125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// <code>code</code> field, which identifies the physical key associated 3135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// with the event. 3145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) KeyboardInputEvent(const InstanceHandle& instance, 3155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) PP_InputEvent_Type type, 3165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) PP_TimeTicks time_stamp, 3175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32_t modifiers, 3185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) uint32_t key_code, 3195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const Var& character_text, 3205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const Var& code); 3215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Returns the DOM keyCode field for the keyboard event. 3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Chrome populates this with the Windows-style Virtual Key code of the key. 3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) uint32_t GetKeyCode() const; 3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Returns the typed character for the given character event. 3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @return A string var representing a single typed character for character 3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// input events. For non-character input events the return value will be an 3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// undefined var. 3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Var GetCharacterText() const; 3325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// Returns the DOM |code| for the keyboard event. 3345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // 3355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// @return A string var representing a physical key that was pressed to 3365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) /// generate this event. 3375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Var GetCode() const; 3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TouchInputEvent : public InputEvent { 3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Constructs an is_null() touch input event object. 3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TouchInputEvent(); 3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Constructs a touch input event object from the given generic input event. 3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// If the given event is itself is_null() or is not a touch input event, the 3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// touch object will be is_null(). 3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) explicit TouchInputEvent(const InputEvent& event); 3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Constructs a touch input even from the given parameters. 3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 352c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) /// @param[in] instance The instance for which this event occurred. 3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of 3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// input event. 3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time 358c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) /// when the event occurred. 3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// 3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @param[in] modifiers A bit field combination of the 3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// <code>PP_InputEvent_Modifier</code> flags. 3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TouchInputEvent(const InstanceHandle& instance, 3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_InputEvent_Type type, 3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PP_TimeTicks time_stamp, 3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) uint32_t modifiers); 3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// Adds the touch-point to the specified TouchList. 3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void AddTouchPoint(PP_TouchListType list, PP_TouchPoint point); 3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @return The number of TouchPoints in this TouchList. 3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) uint32_t GetTouchCount(PP_TouchListType list) const; 3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @return The TouchPoint at the given index of the given list, or an empty 3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// TouchPoint if the index is out of range. 3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TouchPoint GetTouchByIndex(PP_TouchListType list, uint32_t index) const; 3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// @return The TouchPoint in the given list with the given identifier, or an 3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// empty TouchPoint if the list does not contain a TouchPoint with that 3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /// identifier. 3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TouchPoint GetTouchById(PP_TouchListType list, uint32_t id) const; 3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 383a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)class IMEInputEvent : public InputEvent { 384a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) public: 385a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// Constructs an is_null() IME input event object. 386a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) IMEInputEvent(); 387a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 388a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// Constructs an IME input event object from the provided generic input 389a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// event. If the given event is itself is_null() or is not an IME input 390a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// event, the object will be is_null(). 391a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 392a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @param[in] event A generic input event. 393a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) explicit IMEInputEvent(const InputEvent& event); 394a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 395a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// This constructor manually constructs an IME event from the provided 396a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// parameters. 397a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 398a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @param[in] instance The instance for which this event occurred. 399a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 400a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of 401a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// input event. The type must be one of the ime event types. 402a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 403a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time 404a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// when the event occurred. 405a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 406a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @param[in] text The string returned by <code>GetText</code>. 407a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 408a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @param[in] segment_offsets The array of numbers returned by 409a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// <code>GetSegmentOffset</code>. 410a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 411a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @param[in] target_segment The number returned by 412a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// <code>GetTargetSegment</code>. 413a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 414a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @param[in] selection The range returned by <code>GetSelection</code>. 415a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) IMEInputEvent(const InstanceHandle& instance, 416a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) PP_InputEvent_Type type, 417a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) PP_TimeTicks time_stamp, 418a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) const Var& text, 419a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) const std::vector<uint32_t>& segment_offsets, 420a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) int32_t target_segment, 421a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) const std::pair<uint32_t, uint32_t>& selection); 422a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 423a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// Returns the composition text as a UTF-8 string for the given IME event. 424a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 425a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @return A string var representing the composition text. For non-IME 426a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// input events the return value will be an undefined var. 427a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) Var GetText() const; 4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 429a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// Returns the number of segments in the composition text. 430a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 431a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @return The number of segments. For events other than COMPOSITION_UPDATE, 432a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// returns 0. 433a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) uint32_t GetSegmentNumber() const; 434a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 435a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// Returns the position of the index-th segmentation point in the composition 436a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// text. The position is given by a byte-offset (not a character-offset) of 437a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// the string returned by GetText(). It always satisfies 438a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 0=GetSegmentOffset(0) < ... < GetSegmentOffset(i) < GetSegmentOffset(i+1) 439a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// < ... < GetSegmentOffset(GetSegmentNumber())=(byte-length of GetText()). 440a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// Note that [GetSegmentOffset(i), GetSegmentOffset(i+1)) represents the 441a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// range of the i-th segment, and hence GetSegmentNumber() can be a valid 442a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// argument to this function instead of an off-by-1 error. 443a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 444a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME 445a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// event. 446a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 447a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @param[in] index An integer indicating a segment. 448a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 449a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @return The byte-offset of the segmentation point. If the event is not 450a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// COMPOSITION_UPDATE or index is out of range, returns 0. 451a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) uint32_t GetSegmentOffset(uint32_t index) const; 452a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 453a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// Returns the index of the current target segment of composition. 454a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 455a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @return An integer indicating the index of the target segment. When there 456a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// is no active target segment, or the event is not COMPOSITION_UPDATE, 457a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// returns -1. 458a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) int32_t GetTargetSegment() const; 459a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 460a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// Obtains the range selected by caret in the composition text. 461a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 462a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @param[out] start An integer indicating a start offset of selection range. 463a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// 464a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) /// @param[out] end An integer indicating an end offset of selection range. 465a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) void GetSelection(uint32_t* start, uint32_t* end) const; 466a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}; 4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace pp 4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // PPAPI_CPP_INPUT_EVENT_H_ 470