GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/input/mouseinput.h Lines: 0 26 0.0 %
Date: 2017-11-29 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2012-2017  The ManaPlus Developers
4
 *
5
 *  This file is part of The ManaPlus Client.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
/*      _______   __   __   __   ______   __   __   _______   __   __
22
 *     / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___  /\ /  |\/ /\
23
 *    / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
24
 *   / / /__   / / // / // / // / /    / ___  / // ___  / // /| ' / /
25
 *  / /_// /\ / /_// / // / // /_/_   / / // / // /\_/ / // / |  / /
26
 * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
27
 * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
28
 *
29
 * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
30
 *
31
 *
32
 * Per Larsson a.k.a finalman
33
 * Olof Naessén a.k.a jansem/yakslem
34
 *
35
 * Visit: http://guichan.sourceforge.net
36
 *
37
 * License: (BSD)
38
 * Redistribution and use in source and binary forms, with or without
39
 * modification, are permitted provided that the following conditions
40
 * are met:
41
 * 1. Redistributions of source code must retain the above copyright
42
 *    notice, this list of conditions and the following disclaimer.
43
 * 2. Redistributions in binary form must reproduce the above copyright
44
 *    notice, this list of conditions and the following disclaimer in
45
 *    the documentation and/or other materials provided with the
46
 *    distribution.
47
 * 3. Neither the name of Guichan nor the names of its contributors may
48
 *    be used to endorse or promote products derived from this software
49
 *    without specific prior written permission.
50
 *
51
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
55
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
56
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
57
 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
58
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
59
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
60
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
61
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62
 */
63
64
#ifndef INPUT_MOUSEINPUT_H
65
#define INPUT_MOUSEINPUT_H
66
67
#include "enums/events/mousebutton.h"
68
#include "enums/events/mouseeventtype.h"
69
70
#include "localconsts.h"
71
72
class MouseInput final
73
{
74
    public:
75
        MouseInput() :
76
            mType(MouseEventType::MOVED),
77
            mButton(MouseButton::EMPTY),
78
            mTimeStamp(0),
79
            mX(0),
80
            mY(0),
81
            mRealX(0),
82
            mRealY(0)
83
        { }
84
85
        MouseInput(const MouseInput &m) :
86
            mType(m.mType),
87
            mButton(m.mButton),
88
            mTimeStamp(m.mTimeStamp),
89
            mX(m.mX),
90
            mY(m.mY),
91
            mRealX(m.mRealX),
92
            mRealY(m.mRealY)
93
        {
94
        }
95
96
        A_DEFAULT_COPY(MouseInput)
97
98
        MouseInput &operator=(const MouseInput &m)
99
        {
100
            mType = m.mType;
101
            mButton = m.mButton;
102
            mTimeStamp = m.mTimeStamp;
103
            mX = m.mX;
104
            mY = m.mY;
105
            mRealX = m.mRealX;
106
            mRealY = m.mRealY;
107
            return *this;
108
        }
109
110
        ~MouseInput()
111
        { }
112
113
        void setType(MouseEventTypeT type) noexcept2
114
        {
115
            mType = type;
116
        }
117
118
        MouseEventTypeT getType() const noexcept2
119
        {
120
            return mType;
121
        }
122
123
        void setButton(MouseButtonT button) noexcept2
124
        {
125
            mButton = button;
126
        }
127
128
        MouseButtonT getButton() const noexcept2
129
        {
130
            return mButton;
131
        }
132
133
        int getTimeStamp() const noexcept2
134
        {
135
            return mTimeStamp;
136
        }
137
138
        void setTimeStamp(int timeStamp) noexcept2
139
        {
140
            mTimeStamp = timeStamp;
141
        }
142
143
        void setX(int x) noexcept2
144
        {
145
            mX = x;
146
        }
147
148
        int getX() const noexcept2
149
        {
150
            return mX;
151
        }
152
153
        void setY(int y) noexcept2
154
        {
155
            mY = y;
156
        }
157
158
        int getY() const noexcept2
159
        {
160
            return mY;
161
        }
162
163
        void setReal(const int x, const int y) noexcept2
164
        { mRealX = x; mRealY = y; }
165
166
        int getRealX() const noexcept2 A_WARN_UNUSED
167
        { return mRealX; }
168
169
        int getRealY() const noexcept2 A_WARN_UNUSED
170
        { return mRealY; }
171
172
#ifdef ANDROID
173
        int getTouchX() const noexcept2 A_WARN_UNUSED
174
        { return mRealX; }
175
176
        int getTouchY() const noexcept2 A_WARN_UNUSED
177
        { return mRealY; }
178
#else  // ANDROID
179
180
        int getTouchX() const noexcept2 A_WARN_UNUSED
181
        { return mX; }
182
183
        int getTouchY() const noexcept2 A_WARN_UNUSED
184
        { return mY; }
185
#endif  // ANDROID
186
187
    protected:
188
        /**
189
         * Holds the type of the mouse input.
190
         */
191
        MouseEventTypeT mType;
192
193
        /**
194
         * Holds the button of the mouse input.
195
         */
196
        MouseButtonT mButton;
197
198
        /**
199
         * Holds the timestamp of the mouse input. Used to
200
         * check for double clicks.
201
         */
202
        int mTimeStamp;
203
204
        /**
205
         * Holds the x coordinate of the mouse input.
206
         */
207
        int mX;
208
209
        /**
210
         * Holds the y coordinate of the mouse input.
211
         */
212
        int mY;
213
214
        int mRealX;
215
216
        int mRealY;
217
};
218
219
#endif  // INPUT_MOUSEINPUT_H