/usr/include/cegui-0.8.4/CEGUI/MouseCursor.h is in libcegui-mk2-dev 0.8.4+dfsg-4ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | /***********************************************************************
created: 21/2/2004
author: Paul D Turner
purpose: Defines interface for the MouseCursor class
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#ifndef _CEGUIMouseCursor_h_
#define _CEGUIMouseCursor_h_
#include "CEGUI/Base.h"
#include "CEGUI/String.h"
#include "CEGUI/Vector.h"
#include "CEGUI/Rect.h"
#include "CEGUI/EventSet.h"
#include "CEGUI/InputEvent.h"
#include "CEGUI/UDim.h"
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4275)
# pragma warning(disable : 4251)
#endif
// Start of CEGUI namespace section
namespace CEGUI
{
//! Class that provides mouse cursor support.
class CEGUIEXPORT MouseCursor :
public EventSet,
public AllocatedObject<MouseCursor>
{
public:
//! Namespace for global events.
static const String EventNamespace;
/** Name of Event fired when the mouse cursor image is changed.
* Handlers are passed a const MouseCursorEventArgs reference with
* MouseCursorEventArgs::mouseCursor set to the MouseCursor that has
* had it's image changed, and MouseCursorEventArgs::image set to the
* Image that is now set for the MouseCursor (may be 0).
*/
static const String EventImageChanged;
/** Name of Event fired when the Image to be used as a default mouse cursor
* image is changed.
* Handlers are passed a const MouseCursorEventArgs reference with
* MouseCursorEventArgs::mouseCursor set to the MouseCursor that has
* had it's default image changed, and MouseCursorEventArgs::image set to
* the Image that is now set as the default (may be 0).
*/
static const String EventDefaultImageChanged;
/*!
\brief
Constructor for MouseCursor objects
*/
MouseCursor(void);
/*!
\brief
Destructor for MouseCursor objects
*/
~MouseCursor(void);
/*!
\brief
Set the current mouse cursor image
\param name
String object holding the name of the desired Image.
\return
Nothing.
\exception UnknownObjectException thrown if Image \a name is not known.
*/
void setImage(const String& name);
/*!
\brief
Set the current mouse cursor image
*/
void setImage(const Image* image);
/*!
\brief
Get the current mouse cursor image
\return
The current image used to draw mouse cursor.
*/
const Image* getImage(void) const {return d_cursorImage;}
/*!
\brief
Set the image to be used as the default mouse cursor.
\param image
Pointer to an image object that is to be used as the default mouse
cursor. To have no cursor rendered by default, you can specify 0 here.
*/
void setDefaultImage(const Image* image);
/*!
\brief
Set the image to be used as the default mouse cursor.
\param name
String object that contains the name of the Image that is to be used.
\exception
UnknownObjectException thrown if no Image named \a name exists.
*/
void setDefaultImage(const String& name);
/*!
\brief
Return the currently set default mouse cursor image
\return
Pointer to the current default image used for the mouse cursor. May
return 0 if default cursor has not been set, or has intentionally
been set to 0 - which results in a blank default cursor.
*/
const Image* getDefaultImage() const;
/*!
\brief
Makes the cursor draw itself
\return
Nothing
*/
void draw(void) const;
/*!
\brief
Set the current mouse cursor position
\param position
Point object describing the new location for the mouse. This will be clipped to within the renderer screen area.
*/
void setPosition(const Vector2f& position);
/*!
\brief
Offset the mouse cursor position by the deltas specified in \a offset.
\param offset
Point object which describes the amount to move the cursor in each axis.
\return
Nothing.
*/
void offsetPosition(const Vector2f& offset);
/*!
\brief
Set the area that the mouse cursor is constrained to.
\param area
Pointer to a Rect object that describes the area of the display that the mouse is allowed to occupy. The given area will be clipped to
the current Renderer screen area - it is never possible for the mouse to leave this area. If this parameter is NULL, the
constraint is set to the size of the current Renderer screen area.
\return
Nothing.
*/
void setConstraintArea(const Rectf* area);
/*!
\brief
Set the area that the mouse cursor is constrained to.
\param area
Pointer to a URect object that describes the area of the display that the mouse is allowed to occupy. The given area will be clipped to
the current Renderer screen area - it is never possible for the mouse to leave this area. If this parameter is NULL, the
constraint is set to the size of the current Renderer screen area.
\return
Nothing.
*/
void setUnifiedConstraintArea(const URect* area);
/*!
\brief
Hides the mouse cursor.
\return
Nothing.
*/
void hide(void) {d_visible = false;}
/*!
\brief
Shows the mouse cursor.
\return
Nothing.
*/
void show(void) {d_visible = true;}
/*!
\brief
Set the visibility of the mouse cursor.
\param visible
'true' to show the mouse cursor, 'false' to hide it.
\return
Nothing.
*/
void setVisible(bool visible) {d_visible = visible;}
/*!
\brief
return whether the mouse cursor is visible.
\return
true if the mouse cursor is visible, false if the mouse cursor is hidden.
*/
bool isVisible(void) const {return d_visible;}
/*!
\brief
Return the current mouse cursor position as a pixel offset from the top-left corner of the display.
\return
Point object describing the mouse cursor position in screen pixels.
*/
Vector2f getPosition(void) const
{ return d_position; }
/*!
\brief
return the current constraint area of the mouse cursor.
\return
Rect object describing the active area that the mouse cursor is constrained to.
*/
Rectf getConstraintArea(void) const;
/*!
\brief
return the current constraint area of the mouse cursor.
\return
URect object describing the active area that the mouse cursor is constrained to.
*/
const URect& getUnifiedConstraintArea(void) const;
/*!
\brief
Return the current mouse cursor position as display resolution independant values.
\return
Point object describing the current mouse cursor position as resolution independant values that
range from 0.0f to 1.0f, where 0.0f represents the left-most and top-most positions, and 1.0f
represents the right-most and bottom-most positions.
*/
Vector2f getDisplayIndependantPosition(void) const;
/*!
\brief
Function used to notify the MouseCursor of changes in the display size.
You normally would not call this directly; rather you would call the
function System::notifyDisplaySizeChanged and that will then call this
function for you.
\param new_size
Size object describing the new display size in pixels.
*/
void notifyDisplaySizeChanged(const Sizef& new_size);
/*!
\brief
Set an explicit size for the mouse cursor image to be drawn at.
This will override the size that is usually obtained directly from the
mouse cursor image and will stay in effect across changes to the mouse
cursor image.
Setting this size to (0, 0) will revert back to using the size as
obtained from the Image itself.
\param size
Reference to a Size object that describes the size at which the cursor
image should be drawn in pixels.
*/
void setExplicitRenderSize(const Sizef& size);
/*!
\brief
Return the explicit render size currently set. A return size of (0, 0)
indicates that the real image size will be used.
*/
const Sizef& getExplicitRenderSize() const;
/*!
\brief
Static function to pre-initialise the mouse cursor position (prior to
MouseCursor instantiation).
Calling this function prior to instantiating MouseCursor will prevent
the mouse having it's position set to the middle of the initial view.
Calling this function after the MouseCursor is instantiated will have
no effect.
\param position
Reference to a point object describing the initial pixel position to
be used for the mouse cursor.
*/
static void setInitialMousePosition(const Vector2f& position);
/*!
\brief
Mark the cached geometry as invalid so it will be recached next time the
mouse cursor is drawn.
*/
void invalidate();
protected:
/*************************************************************************
New event handlers
*************************************************************************/
//! Event triggered internally when mouse cursor image is changed.
virtual void onImageChanged(MouseCursorEventArgs& e);
//! Event triggered internally when mouse cursor default image is changed.
virtual void onDefaultImageChanged(MouseCursorEventArgs& e);
private:
/*************************************************************************
Implementation Methods
*************************************************************************/
/*!
\brief
Checks the mouse cursor position is within the current 'constrain' Rect and adjusts as required.
*/
void constrainPosition(void);
//! updates the cached geometry.
void cacheGeometry() const;
//! calculate offset for custom image size so 'hot spot' is maintained.
void calculateCustomOffset() const;
/*************************************************************************
Implementation Data
*************************************************************************/
//! Image that is currently set as the mouse cursor.
const Image* d_cursorImage;
//! Image that will be used as the default image for this mouse cursor.
const Image* d_defaultCursorImage;
Vector2f d_position; //!< Current location of the cursor
bool d_visible; //!< true if the cursor will be drawn, else false.
URect d_constraints; //!< Specifies the area (in screen pixels) that the mouse can move around in.
//! buffer to hold geometry for mouse cursor imagery.
GeometryBuffer* d_geometry;
//! custom explicit size to render the cursor image at
Sizef d_customSize;
//! correctly scaled offset used when using custom image size.
mutable Vector2f d_customOffset;
//! true if the mouse initial position has been pre-set
static bool s_initialPositionSet;
//! value set as initial position (if any)
static Vector2f s_initialPosition;
//! boolean indicating whether cached pointer geometry is valid.
mutable bool d_cachedGeometryValid;
};
} // End of CEGUI namespace section
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif // end of guard _CEGUIMouseCursor_h_
|