Torque3D Documentation / _generateds / platformCursorController.cpp

platformCursorController.cpp

Engine/source/windowManager/platformCursorController.cpp

More...

Detailed Description

 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2012 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#include "platform/platform.h"
25#include "windowManager/platformCursorController.h"
26
27void PlatformCursorController::pushCursor( S32 cursorID )
28{
29   // Place the new cursor shape onto the stack
30   mCursors.increment();
31
32   Cursor_Shape &shape = mCursors.last();
33   shape.mCursorType  = Cursor_Shape::TYPE_RESOURCE;
34   shape.mCursorID    = cursorID;
35
36   // Now Change the Cursor Shape.
37   setCursorShape( shape.mCursorID );
38}
39
40void PlatformCursorController::pushCursor( const UTF8 *fileName )
41{
42   // Place the new cursor shape onto the stack
43   mCursors.increment();
44
45   // Store the Details.
46   Cursor_Shape &shape = mCursors.last();
47   shape.mCursorType  = Cursor_Shape::TYPE_FILE;
48   shape.mCursorFile  = String::ToString( "%s", fileName );
49
50   // Now Change the Cursor Shape.
51   setCursorShape( shape.mCursorFile.c_str(), true );
52}
53
54void PlatformCursorController::popCursor()
55{
56   // Before poping the stack, make sure we're not trying to remove the last cursor shape
57   if ( mCursors.size() <= 1 )
58   {
59      return;
60   }
61
62   // Clear the Last Cursor.
63   mCursors.pop_back();
64
65   // Now Change the Cursor Shape.
66   setCursorShape( mCursors.last(), true );
67}
68
69void PlatformCursorController::refreshCursor()
70{
71   // Refresh the Cursor Shape.
72   setCursorShape( mCursors.last(), false );
73}
74
75void PlatformCursorController::setCursorShape( const Cursor_Shape &shape, bool reload )
76{
77    switch( shape.mCursorType )
78    {
79        case Cursor_Shape::TYPE_RESOURCE :
80            {
81
82                // Set Resource.
83                setCursorShape( shape.mCursorID );
84
85            } break;
86
87        case Cursor_Shape::TYPE_FILE :
88            {
89
90                // Set File.
91                setCursorShape( shape.mCursorFile.c_str(), reload );
92
93            } break;
94    }
95}
96