MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
eventgamewindow.h
1 // © Copyright 2010 - 2014 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef EVENTGAMEWINDOW_H
41 #define EVENTGAMEWINDOW_H
42 ///////////////////////////////////////////////////////////////////////////////
43 // This will store the amount of time since rendering events that occured recently
44 ///////////////////////////////////////
45 
46 #include "crossplatformexport.h"
47 #include "eventbase.h"
48 #ifndef SWIG
49  #include "XML/xml.h"
50 #endif
51 
52 namespace Mezzanine
53 {
54  class EventGameWindowData;
55 
56  ///////////////////////////////////////////////////////////////////////////////
57  /// @class EventGameWindow
58  /// @headerfile eventgamewindow.h
59  /// @brief Convey the message that Something happened to a game window
60  /// @details
62  {
63  public:
64  /// @brief Used to identify the kind of change that has happened to the game window.
65  typedef enum
66  {
67  GAME_WINDOW_NONE=0, /**< Never used */
68  GAME_WINDOW_FIRST = GAME_WINDOW_NONE, /**< Used only as the lower bounds of this enumeration*/
69 
70  GAME_WINDOW_SHOWN = 1, /**< Window has been shown */
71  GAME_WINDOW_HIDDEN = 2, /**< Window has been hidden */
72  GAME_WINDOW_EXPOSED = 3, /**< Window has been exposed and should be redrawn */
73 
74  GAME_WINDOW_MOVED = 4, /**< Window has been moved to data1, data2 */
75 
76  GAME_WINDOW_RESIZED = 5, /**< Window has been resized to data1xdata2 */
77  GAME_WINDOW_SIZE_CHANGED = 6, /**< The window size has changed, either as a result of an API call or through the system or user changing the window size. */
78  GAME_WINDOW_MINIMIZED = 7, /**< Window has been minimized */
79  GAME_WINDOW_MAXIMIZED = 8, /**< Window has been maximized */
80  GAME_WINDOW_RESTORED = 9, /**< Window has been restored to normal size and position */
81 
82  GAME_WINDOW_ENTER = 10, /**< Window has gained mouse focus */
83  GAME_WINDOW_LEAVE = 11, /**< Window has lost mouse focus */
84  GAME_WINDOW_FOCUS_GAINED = 12, /**< Window has gained keyboard focus */
85  GAME_WINDOW_FOCUS_LOST = 13, /**< Window has lost keyboard focus */
86 
87  GAME_WINDOW_CLOSE = 14, /**< The window manager requests that the window be closed */
88  GAME_WINDOW_LAST = GAME_WINDOW_CLOSE /**< Used only as the Upper bounds of this enumeration*/
89  } GameWindowEventID;
90 
91  /// @brief Creates an EventGameWindow from a Rawevent
92  /// @param Raw_ The RawEvent to decompose to use for the values of this EventGameWindow
93  explicit EventGameWindow(RawEvent Raw_);
94 
95  /// @brief Creates an EventGameWindow from manually assigned values
96  /// @param GWEventID What kind of change happened
97  /// @param First A parameter that is dependant on the kind of change to the game window
98  /// @param Second A parameter that is dependant on the kind of change to the game window
99  explicit EventGameWindow(GameWindowEventID GWEventID=GAME_WINDOW_NONE, int First=0, int Second=0);
100 
101  /// @brief Copy constructor
102  /// @param Other The Other EventGameWindow to use in the creation on this
103  EventGameWindow( const EventGameWindow& Other);
104 
105  /// @brief Deconstructs this EventGameWindow
106  virtual ~EventGameWindow();
107 
108  /// @brief This returns EventType::GameWindow
109  /// @details This returns the kind of message this is, specifcally EventType::GameWindow . If
110  /// this functions returns EventType::GameWindow, then and event pointer can safely be
111  /// cast to Mezzanine::EventGameWindow . This method is inherited from Mezzanine::Event .
112  virtual EventType GetType() const;
113 
114  /// @brief What just happened, what kind of event was it.
115  /// @return A GameWindowEventID indicating what happened.
116  GameWindowEventID GetEventID() const;
117 
118  /// @brief Where or how much happened, Get the first event dependent data.
119  /// @return An int with some details about the the event that happened.
120  /// @details Currently this provides the x values for the new window locations in the event that a window moves, or it
121  /// is resized. If moved it has the new location, if resized it has the new size. This may be used in places in the future.
122  int GetFirstEventData() const;
123 
124  /// @brief Where or how much happened, Get the second event dependent data.
125  /// @details Currently this provides the y values for the new window locations in the event that a window moves, or it
126  /// is resized. If moved it has the new location, if resized it has the new size. This may be used in places in the future.
127  /// @return An int with some details about the the event that happened.
128  int GetSecondEventData() const;
129 
130  /// @brief Converts GameWindowEventID To Strings
131  /// @param GWEventID the GameWindowEventID to get as a string
132  /// @return This returns a string containg the GameWindowEventID in a string as a developer would have typed it.
133  static String GameWindowEventIDToString(EventGameWindow::GameWindowEventID GWEventID);
134 
135  /// @internal
136  /// @brief Used to help determine if this Event is valid by checking the contents of the GameWindowEventID
137  /// @return True if the event if is between GAME_WINDOW_FIRST and GAME_WINDOW_LAST, false otherwise
138  bool IsEventIDValid() const;
139 
140  /// @brief Assignment of a this EventGameWindowData
141  /// @param Other the other EventGameWindow to overwite this one.
142  void operator=(const EventGameWindow& Other);
143 
144  /// @brief Equality comparison of two EventGameWindowData
145  /// @param Other the other EventGameWindow to compare to this one
146  /// @return True if identical, false if otherwise.
147  bool operator==(const EventGameWindow& Other) const;
148 
149  /// @brief Equality comparison of this EventGameWindowData and a GameWindowEventID
150  /// @param Other the other GameWindowEventID to compare to the one stored in this.
151  /// @return True if the GameWindowEventID in this event matches the Other, false if otherwise.
152  bool operator==(const GameWindowEventID& Other) const;
153 
154  protected:
155  /// @internal
156  /// @brief Holds all internal data
158 
159  private:
160  /// @internal
161  /// @brief Sets the internal values.
162  /// @param Raw_ The RawEvent to decompose to use for the values of this EventGameWindow
163  void construct(RawEvent Raw_);
164 
165  /// @internal
166  /// @brief Sets the internal values.
167  /// @param GWEventID What kind of change happened
168  /// @param First A parameter that is dependant on the kind of change to the game window
169  /// @param Second A parameter that is dependant on the kind of change to the game window
170  void construct(GameWindowEventID GWEventID, int First, int Second);
171  };
172 }
173 
174 ///////////////////////////////////////////////////////////////////////////////
175 // Class External << Operators for streaming or assignment
176 
177 /// @brief Serializes the passed Mezzanine::EventGameWindow to XML
178 /// @param stream The ostream to send the xml to.
179 /// @param Ev the Mezzanine::EventGameWindow to be serialized
180 /// @return this returns the ostream, now with the serialized data
181 std::ostream& MEZZ_LIB operator << (std::ostream& stream, const Mezzanine::EventGameWindow& Ev);
182 
183 /// @brief Deserialize a Mezzanine::EventGameWindow
184 /// @param stream The istream to get the xml from to (re)make the Mezzanine::EventGameWindow.
185 /// @param Ev the Mezzanine::EventGameWindow to be deserialized.
186 /// @return this returns the ostream, advanced past the Mezzanine::EventGameWindow that was recreated onto Ev.
187 std::istream& MEZZ_LIB operator >> (std::istream& stream, Mezzanine::EventGameWindow& Ev);
188 
189 /// @brief Set all values of a Mezzanine::EventGameWindow from parsed xml.
190 /// @param OneNode The istream to get the xml from to (re)make the Mezzanine::EventGameWindow.
191 /// @param Ev the Mezzanine::EventGameWindow to be reset.
192 /// @return This returns theXML::Node that was passed in.
193 const Mezzanine::XML::Node& MEZZ_LIB operator >> (const Mezzanine::XML::Node& OneNode, Mezzanine::EventGameWindow& Ev);
194 
196 
197 #endif
198