SO3Engine
SO3WidgetManager.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
32#ifndef _SO3_WIDGET_MANAGER_H_
33#define _SO3_WIDGET_MANAGER_H_
34
35#include <Ogre.h>
37#include "SO3WidgetFactory.h"
38#include "SO3WidgetListener.h"
39
40namespace SO3
41{
43 {
44 public:
45 int index;
46 int x;
47 int y;
49 protected:
50 private:
51 public:
56 {
57 x = 0;
58 y = 0;
59 index = 0;
60 widget = nullptr;
61 }
62
66 INPUTInfo(int cindex, int cx, int cy, SWidget* wg)
67 {
68 index = cindex;
69 x = cx;
70 y = cy;
71 widget = wg;
72 }
73
77 INPUTInfo(const INPUTInfo& input)
78 {
79 index = input.index;
80 x = input.x;
81 y = input.y;
82 widget = input.widget;
83 }
84
89 {
90 }
91 protected:
92 private:
93 };
94
97class _SO3_Export SWidgetManager : public Ogre::Singleton<SWidgetManager>
98{
99public:
100 typedef std::map<std::string, SWidget*> WidgetList;
101protected:
102private:
103 typedef std::map<std::string, SWidgetFactory*> WidgetFactoryList;
104 typedef std::map<int, INPUTInfo> WidgetInputList;
105 typedef std::multimap<unsigned short, SWidget*> WidgetListByZOrder;
106 typedef std::set<SWidgetListener*> WidgetListenerList;
107 WidgetFactoryList widgetFactoryList;
108 WidgetList widgetList;
109 WidgetList overlayedWidgetList;
110 WidgetListByZOrder widgetListByZOrder;
111 WidgetListenerList widgetListenerList;
112 SWidget* focusedWidget;
113 WidgetInputList inputList;
114
115public:
120
125
128 WidgetList GetWidgetList();
129
132 void AddWidgetFactory(SWidgetFactory* newWidgetFactory);
133
136 void RemoveWidgetFactory(SWidgetFactory* existingWidgetFactory);
137
140 void RemoveWidgetFactory(const std::string& existingWidgetFactoryName);
141
145 SWidget* CreateWidget(SScene* targetScene, const std::string& widgetName, const int& xPos, const int& yPos, const unsigned short& width, const unsigned short& height, SViewPort* targetViewport, const unsigned int& widgetZOrder, const std::string& widgetType);
146
150 SWidget* CreateWidget(SScene* targetScene, const std::string& widgetName, const int& xPos, const int& yPos, const unsigned short& width, const unsigned short& height, SViewPort* targetViewport, const std::string& widgetType);
151
155 SWidget* CreateWidget(SScene* targetScene, const std::string& widgetName, const unsigned short& width, const unsigned short& height, SMaterial* targetMaterial, const unsigned short& targetTechnique, const unsigned short& targetPass, const unsigned short& targetTextureUnit, const std::string& widgetType);
156
159 void DeleteWidget(SWidget* existingWidget);
160
163 void AddWidgetListener(SWidgetListener* newWidgetListener);
164
167 void RemoveWidgetListener(SWidgetListener* existingWidgetListener);
168
172 static SWidgetManager& getSingleton();
173
174 /*
175 @copydoc Ogre::Singleton::getSingletonPtr
176 */
177 static SWidgetManager* getSingletonPtr();
178
186 void InjectMouseMove(SWindow* originWindow, const int& xPos, const int& yPos, const MouseButtonId& button);
187
195 void InjectMouseWheel(SWindow* originWindow, const int& scrollX, const int& scrollY, const int& relativeScroll);
196
204 void InjectMouseDown(SWindow* originWindow, const int& xPos, const int& yPos, const MouseButtonId& button);
205
206 void InjectTouchAdd(SWindow* originWindow, const int& xPos, const int& yPos, const int& touchid);
207
208 void InjectTouchRemove(SWindow* originWindow, const int& touchid);
209
210 void InjectTouchUpdate(SWindow* originWindow, const int& xPos, const int& yPos, const int& vx, const int& vy, const int& touchid);
211
219 void InjectMouseUp(SWindow* originWindow, const int& xPos, const int& yPos, const MouseButtonId& button);
220
221 void InjectMouseMove(SWidget* widget, const SRaycastResult& raycast, const MouseButtonId& button, const int& id = 0);
222
223 void InjectMouseDown(SWidget* widget, const SRaycastResult& raycast, const MouseButtonId& button, const int& id = 0);
224
225 void InjectMouseUp(const SRaycastResult& raycast, const MouseButtonId& button, const int& id = 0);
226
227 void InjectMouseWheel(SWidget* widget, const SRaycastResult& raycast, const int& relativeScroll, const int& id = 0);
228
229 void InjectTouchAdd(SWidget* widget, const SRaycastResult& raycast, const int& touchid);
230
231 void InjectTouchRemove(SWidget* widget, const SRaycastResult& raycast, const int& touchid);
232
233 void InjectTouchUpdate(SWidget* widget, const SRaycastResult& raycast, const int& touchid);
234
237 void InjectKeyEvent(const UINT& msg, const ScolWindowHandle& hwnd, const WPARAM& wParam, const LPARAM& lParam);
238
241 void InjectTextEvent(const std::string& text);
242
245 void UpdateWidgetsZOrder();
246
249 void UpdateFocusedWidget(SWidget* focusTargetedWidget);
250
253 SWidget* GetFocusedWidget();
254
258 void _FireScriptWidgetEvent(SWidget* targetedWidget, const SScriptFunction& functionCalled);
259
263 void _FireOnLoadStart(SWidget* targetedWidget);
264
268 void _FireOnLoadEnd(SWidget* targetedWidget);
269
273 void _FireOnLoadError(SWidget* targetedWidget, const int& errorCode, const std::string& failedUrl);
274protected:
275private:
278 SWidget* GetWidgetUnder(SWindow* originWindow, const int& posX, const int& posY, const int& id = 0);
279
282 void _FireEnterWidgetEvent(SWidget* targetedWidget, const int& id = 0);
283
286 void _FireInsideWidgetEvent(SWidget* targetedWidget, const int& id = 0);
287
290 void _FireExitWidgetEvent(SWidget* targetedWidget, const int& id = 0);
291
294 void _FireMouseMoveWidgetEvent(SWidget* targetedWidget, const int& mousePosX, const int& mousePosY, const MouseButtonId& mouseButton, const int& id = 0);
295
298 void _FireMouseDownWidgetEvent(SWidget* targetedWidget, const int& mousePosX, const int& mousePosY, const MouseButtonId& mouseButton, const int& id = 0);
299
302 void _FireMouseUpWidgetEvent(SWidget* targetedWidget, const int& mousePosX, const int& mousePosY, const MouseButtonId& mouseButton, const int& id = 0);
303
306 void _FireMouseWheelWidgetEvent(SWidget* targetedWidget, const int& mousePosX, const int& mousePosY, const int& relativeScroll, const int& id = 0);
307
310 void _FireTouchAddWidgetEvent(SWidget* targetedWidget, const int& mousePosX, const int& mousePosY, const int& touchid);
311
314 void _FireTouchRemoveWidgetEvent(SWidget* targetedWidget, const int& mousePosX, const int& mousePosY, const int& touchid);
315
318 void _FireTouchUpdateWidgetEvent(SWidget* targetedWidget, const int& mousePosX, const int& mousePosY, const int& vx, const int& vy, const int& touchid);
319
322 void _FireKeyWidgetEvent(SWidget* targetedWidget, const UINT& msg, const ScolWindowHandle& hwnd, const UINT& wParam, const LONG& lParam);
323
326 void _FireFocusWidgetEvent(SWidget* targetedWidget, const bool& focused);
327
330 SPointInt ConvertTextureUvToWidgetCoordinates(SWidget* targetedWidget, const float& uCoordinates, const float& vCoordinates);
331};
332
333}
334
335#endif
long LONG
Definition SO3Android.h:59
unsigned int UINT
Definition SO3Android.h:58
librairies include
INPUTInfo(int cindex, int cx, int cy, SWidget *wg)
INPUTInfo(const INPUTInfo &input)
std::map< std::string, SWidget * > WidgetList