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_MOUSE_CURSOR_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PPAPI_CPP_MOUSE_CURSOR_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_mouse_cursor.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/image_data.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/instance_handle.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/cpp/point.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace pp {
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class MouseCursor {
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// Sets the given mouse cursor. The mouse cursor will be in effect whenever
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// the mouse is over the given instance until it is set again by another
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// call. Note that you can hide the mouse cursor by setting it to the
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// <code>PP_MOUSECURSOR_TYPE_NONE</code> type.
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ///
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// This function allows setting both system defined mouse cursors and
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// custom cursors. To set a system-defined cursor, pass the type you want
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// and set the custom image to a default-constructor ImageData object.
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// To set a custom cursor, set the type to
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// <code>PP_MOUSECURSOR_TYPE_CUSTOM</code> and specify your image and hot
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// spot.
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ///
29c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  /// @param[in] instance A handle identifying the instance that the mouse
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// cursor will affect.
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ///
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// @param[in] type A <code>PP_MouseCursor_Type</code> identifying the type
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// of mouse cursor to show. See <code>ppapi/c/ppb_mouse_cursor.h</code>.
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ///
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// @param[in] image A <code>ImageData</code> object identifying the
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// custom image to set when the type is
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// <code>PP_MOUSECURSOR_TYPE_CUSTOM</code>. The image must be less than 32
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// pixels in each direction and must be of the system's native image format.
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// When you are specifying a predefined cursor, this parameter should be a
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// default-constructed ImageData.
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ///
42c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  /// @param[in] hot_spot When setting a custom cursor, this identifies the
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// pixel position within the given image of the "hot spot" of the cursor.
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// When specifying a stock cursor, this parameter is ignored.
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ///
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// @return true on success, or false if the instance or cursor type
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /// was invalid or if the image was too large.
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool SetCursor(const InstanceHandle& instance,
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        PP_MouseCursor_Type type,
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const ImageData& image = ImageData(),
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const Point& hot_spot = Point(0, 0));
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace pp
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // PPAPI_CPP_MOUSE_CURSOR_H_
57