1 /***************************************************************************
2  *   Copyright (C) 2005-2019 by the FIFE team                              *
3  *   http://www.fifengine.net                                              *
4  *   This file is part of FIFE.                                            *
5  *                                                                         *
6  *   FIFE is free software; you can redistribute it and/or                 *
7  *   modify it under the terms of the GNU Lesser General Public            *
8  *   License as published by the Free Software Foundation; either          *
9  *   version 2.1 of the License, or (at your option) any later version.    *
10  *                                                                         *
11  *   This library is distributed in the hope that it will be useful,       *
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
14  *   Lesser General Public License for more details.                       *
15  *                                                                         *
16  *   You should have received a copy of the GNU Lesser General Public      *
17  *   License along with this library; if not, write to the                 *
18  *   Free Software Foundation, Inc.,                                       *
19  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
20  ***************************************************************************/
21 
22 #ifndef FIFE_EVENTCHANNEL_TEXTEVENT_H
23 #define FIFE_EVENTCHANNEL_TEXTEVENT_H
24 
25 // Standard C++ library includes
26 //
27 
28 // 3rd party library includes
29 //
30 
31 // FIFE includes
32 // These includes are split up in two parts, separated by one empty line
33 // First block: files included from the FIFE root src directory
34 // Second block: files included from the same folder
35 //
36 #include "eventchannel/base/inputevent.h"
37 #include "eventchannel/source/ieventsource.h"
38 
39 #include "text.h"
40 
41 namespace FIFE {
42 
43 	/**  Class for text events
44 	 */
45 	class TextEvent: public InputEvent {
46 	public:
47 		enum TextEventType {
48 			UNKNOWN		= 0,
49 			INPUT		= 1,
50 			EDIT		= 2
51 		};
52 
53 		/** Constructor
54 		 */
TextEvent()55 		TextEvent():
56 			InputEvent(),
57 			m_eventType(UNKNOWN),
58 			m_text(Text()) {}
59 
60 		/** Destructor.
61 		 */
~TextEvent()62 		virtual ~TextEvent() {}
63 
getType()64 		TextEventType getType() const { return m_eventType; }
setType(TextEventType type)65 		void setType(TextEventType type) { m_eventType = type; }
66 
getText()67 		const Text& getText() const { return m_text; }
setText(const Text & text)68 		void setText(const Text& text) { m_text = text; }
69 
consume()70 		virtual void consume() { InputEvent::consume(); }
isConsumed()71 		virtual bool isConsumed() const { return InputEvent::isConsumed(); }
consumedByWidgets()72 		virtual void consumedByWidgets() { InputEvent::consumedByWidgets(); }
isConsumedByWidgets()73 		virtual bool isConsumedByWidgets() const { return InputEvent::isConsumedByWidgets(); }
getSource()74 		virtual IEventSource* getSource() const { return InputEvent::getSource(); }
setSource(IEventSource * source)75 		virtual void setSource(IEventSource* source) { InputEvent::setSource(source); }
getTimeStamp()76 		virtual int32_t getTimeStamp() const { return InputEvent::getTimeStamp(); }
setTimeStamp(int32_t timestamp)77 		virtual void setTimeStamp(int32_t timestamp ) { InputEvent::setTimeStamp(timestamp); }
78 
getName()79 		virtual const std::string& getName() const {
80 			const static std::string eventName("TextEvent");
81 			return eventName;
82 		}
getDebugString()83 		virtual std::string getDebugString() const { return InputEvent::getDebugString(); }
84 
85 	private:
86 		TextEventType m_eventType;
87 		Text m_text;
88 	};
89 
90 } //FIFE
91 
92 #endif
93