aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIEnvironment.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CGUIEnvironment.h')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CGUIEnvironment.h323
1 files changed, 323 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIEnvironment.h b/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIEnvironment.h
new file mode 100644
index 0000000..6b3be3b
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CGUIEnvironment.h
@@ -0,0 +1,323 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __C_GUI_ENVIRONMENT_H_INCLUDED__
6#define __C_GUI_ENVIRONMENT_H_INCLUDED__
7
8#include "IrrCompileConfig.h"
9#ifdef _IRR_COMPILE_WITH_GUI_
10
11#include "IGUIEnvironment.h"
12#include "IGUIElement.h"
13#include "irrArray.h"
14#include "IFileSystem.h"
15#include "IOSOperator.h"
16
17namespace irr
18{
19namespace io
20{
21 class IXMLWriter;
22}
23namespace gui
24{
25
26class CGUIEnvironment : public IGUIEnvironment, public IGUIElement
27{
28public:
29
30 //! constructor
31 CGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* driver, IOSOperator* op);
32
33 //! destructor
34 virtual ~CGUIEnvironment();
35
36 //! draws all gui elements
37 virtual void drawAll();
38
39 //! returns the current video driver
40 virtual video::IVideoDriver* getVideoDriver() const;
41
42 //! returns pointer to the filesystem
43 virtual io::IFileSystem* getFileSystem() const;
44
45 //! returns a pointer to the OS operator
46 virtual IOSOperator* getOSOperator() const;
47
48 //! posts an input event to the environment
49 virtual bool postEventFromUser(const SEvent& event);
50
51 //! This sets a new event receiver for gui events. Usually you do not have to
52 //! use this method, it is used by the internal engine.
53 virtual void setUserEventReceiver(IEventReceiver* evr);
54
55 //! removes all elements from the environment
56 virtual void clear();
57
58 //! called if an event happened.
59 virtual bool OnEvent(const SEvent& event);
60
61 //! returns the current gui skin
62 virtual IGUISkin* getSkin() const;
63
64 //! Sets a new GUI Skin
65 virtual void setSkin(IGUISkin* skin);
66
67 //! Creates a new GUI Skin based on a template.
68 /** \return Returns a pointer to the created skin.
69 If you no longer need the skin, you should call IGUISkin::drop().
70 See IReferenceCounted::drop() for more information. */
71 virtual IGUISkin* createSkin(EGUI_SKIN_TYPE type);
72
73 //! Creates the image list from the given texture.
74 virtual IGUIImageList* createImageList( video::ITexture* texture,
75 core::dimension2d<s32> imageSize, bool useAlphaChannel );
76
77 //! returns the font
78 virtual IGUIFont* getFont(const io::path& filename);
79
80 //! add an externally loaded font
81 virtual IGUIFont* addFont(const io::path& name, IGUIFont* font);
82
83 //! remove loaded font
84 virtual void removeFont(IGUIFont* font);
85
86 //! returns default font
87 virtual IGUIFont* getBuiltInFont() const;
88
89 //! returns the sprite bank
90 virtual IGUISpriteBank* getSpriteBank(const io::path& filename);
91
92 //! returns the sprite bank
93 virtual IGUISpriteBank* addEmptySpriteBank(const io::path& name);
94
95 //! adds an button. The returned pointer must not be dropped.
96 virtual IGUIButton* addButton(const core::rect<s32>& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0,const wchar_t* tooltiptext = 0);
97
98 //! adds a window. The returned pointer must not be dropped.
99 virtual IGUIWindow* addWindow(const core::rect<s32>& rectangle, bool modal = false,
100 const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1);
101
102 //! adds a modal screen. The returned pointer must not be dropped.
103 virtual IGUIElement* addModalScreen(IGUIElement* parent);
104
105 //! Adds a message box.
106 virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0,
107 bool modal = true, s32 flag = EMBF_OK, IGUIElement* parent=0, s32 id=-1, video::ITexture* image=0);
108
109 //! adds a scrollbar. The returned pointer must not be dropped.
110 virtual IGUIScrollBar* addScrollBar(bool horizontal, const core::rect<s32>& rectangle,
111 IGUIElement* parent=0, s32 id=-1);
112
113 //! Adds an image element.
114 virtual IGUIImage* addImage(video::ITexture* image, core::position2d<s32> pos,
115 bool useAlphaChannel=true, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0);
116
117 //! adds an image. The returned pointer must not be dropped.
118 virtual IGUIImage* addImage(const core::rect<s32>& rectangle,
119 IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0, bool useAlphaChannel=true);
120
121 //! adds a checkbox
122 virtual IGUICheckBox* addCheckBox(bool checked, const core::rect<s32>& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0);
123
124 //! adds a list box
125 virtual IGUIListBox* addListBox(const core::rect<s32>& rectangle,
126 IGUIElement* parent=0, s32 id=-1, bool drawBackground=false);
127
128 //! adds a tree view
129 virtual IGUITreeView* addTreeView(const core::rect<s32>& rectangle,
130 IGUIElement* parent=0, s32 id=-1, bool drawBackground=false,
131 bool scrollBarVertical = true, bool scrollBarHorizontal = false);
132
133 //! adds an mesh viewer. The returned pointer must not be dropped.
134 virtual IGUIMeshViewer* addMeshViewer(const core::rect<s32>& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0);
135
136 //! Adds a file open dialog.
137 virtual IGUIFileOpenDialog* addFileOpenDialog(const wchar_t* title = 0,
138 bool modal=true, IGUIElement* parent=0, s32 id=-1,
139 bool restoreCWD=false, io::path::char_type* startDir=0);
140
141 //! Adds a color select dialog.
142 virtual IGUIColorSelectDialog* addColorSelectDialog(const wchar_t* title = 0, bool modal=true, IGUIElement* parent=0, s32 id=-1);
143
144 //! adds a static text. The returned pointer must not be dropped.
145 virtual IGUIStaticText* addStaticText(const wchar_t* text, const core::rect<s32>& rectangle,
146 bool border=false, bool wordWrap=true, IGUIElement* parent=0, s32 id=-1, bool drawBackground = false);
147
148 //! Adds an edit box. The returned pointer must not be dropped.
149 virtual IGUIEditBox* addEditBox(const wchar_t* text, const core::rect<s32>& rectangle,
150 bool border=false, IGUIElement* parent=0, s32 id=-1);
151
152 //! Adds a spin box to the environment
153 virtual IGUISpinBox* addSpinBox(const wchar_t* text, const core::rect<s32>& rectangle,
154 bool border=false,IGUIElement* parent=0, s32 id=-1);
155
156 //! Adds a tab control to the environment.
157 virtual IGUITabControl* addTabControl(const core::rect<s32>& rectangle,
158 IGUIElement* parent=0, bool fillbackground=false, bool border=true, s32 id=-1);
159
160 //! Adds tab to the environment.
161 virtual IGUITab* addTab(const core::rect<s32>& rectangle,
162 IGUIElement* parent=0, s32 id=-1);
163
164 //! Adds a context menu to the environment.
165 virtual IGUIContextMenu* addContextMenu(const core::rect<s32>& rectangle,
166 IGUIElement* parent=0, s32 id=-1);
167
168 //! Adds a menu to the environment.
169 virtual IGUIContextMenu* addMenu(IGUIElement* parent=0, s32 id=-1);
170
171 //! Adds a toolbar to the environment. It is like a menu is always placed on top
172 //! in its parent, and contains buttons.
173 virtual IGUIToolBar* addToolBar(IGUIElement* parent=0, s32 id=-1);
174
175 //! Adds a combo box to the environment.
176 virtual IGUIComboBox* addComboBox(const core::rect<s32>& rectangle,
177 IGUIElement* parent=0, s32 id=-1);
178
179 //! Adds a table element.
180 virtual IGUITable* addTable(const core::rect<s32>& rectangle,
181 IGUIElement* parent=0, s32 id=-1, bool drawBackground=false);
182
183 //! sets the focus to an element
184 virtual bool setFocus(IGUIElement* element);
185
186 //! removes the focus from an element
187 virtual bool removeFocus(IGUIElement* element);
188
189 //! Returns if the element has focus
190 virtual bool hasFocus(IGUIElement* element) const;
191
192 //! Returns the element with the focus
193 virtual IGUIElement* getFocus() const;
194
195 //! Returns the element last known to be under the mouse
196 virtual IGUIElement* getHovered() const;
197
198 //! Adds an element for fading in or out.
199 virtual IGUIInOutFader* addInOutFader(const core::rect<s32>* rectangle=0, IGUIElement* parent=0, s32 id=-1);
200
201 //! Returns the root gui element.
202 virtual IGUIElement* getRootGUIElement();
203
204 virtual void OnPostRender( u32 time );
205
206 //! Returns the default element factory which can create all built in elements
207 virtual IGUIElementFactory* getDefaultGUIElementFactory() const;
208
209 //! Adds an element factory to the gui environment.
210 /** Use this to extend the gui environment with new element types which it should be
211 able to create automaticly, for example when loading data from xml files. */
212 virtual void registerGUIElementFactory(IGUIElementFactory* factoryToAdd);
213
214 //! Returns amount of registered scene node factories.
215 virtual u32 getRegisteredGUIElementFactoryCount() const;
216
217 //! Returns a scene node factory by index
218 virtual IGUIElementFactory* getGUIElementFactory(u32 index) const;
219
220 //! Adds a GUI Element by its name
221 virtual IGUIElement* addGUIElement(const c8* elementName, IGUIElement* parent=0);
222
223 //! Saves the current gui into a file.
224 /** \param filename: Name of the file.
225 \param start: The element to start saving from.
226 if not specified, the root element will be used */
227 virtual bool saveGUI( const io::path& filename, IGUIElement* start=0);
228
229 //! Saves the current gui into a file.
230 /** \param file: The file to save the GUI to.
231 \param start: The element to start saving from.
232 if not specified, the root element will be used */
233 virtual bool saveGUI(io::IWriteFile* file, IGUIElement* start=0);
234
235 //! Loads the gui. Note that the current gui is not cleared before.
236 /** \param filename: Name of the file.
237 \param parent: The parent of all loaded GUI elements,
238 if not specified, the root element will be used */
239 virtual bool loadGUI(const io::path& filename, IGUIElement* parent=0);
240
241 //! Loads the gui. Note that the current gui is not cleared before.
242 /** \param file: IReadFile to load the GUI from
243 \param parent: The parent of all loaded GUI elements,
244 if not specified, the root element will be used */
245 virtual bool loadGUI(io::IReadFile* file, IGUIElement* parent=0);
246
247 //! Writes attributes of the environment
248 virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const;
249
250 //! Reads attributes of the environment.
251 virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);
252
253 //! writes an element
254 virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* node);
255
256 //! reads an element
257 virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* node);
258
259private:
260
261 IGUIElement* getNextElement(bool reverse=false, bool group=false);
262
263 void updateHoveredElement(core::position2d<s32> mousePos);
264
265 void loadBuiltInFont();
266
267 struct SFont
268 {
269 io::SNamedPath NamedPath;
270 IGUIFont* Font;
271
272 bool operator < (const SFont& other) const
273 {
274 return (NamedPath < other.NamedPath);
275 }
276 };
277
278 struct SSpriteBank
279 {
280 io::SNamedPath NamedPath;
281 IGUISpriteBank* Bank;
282
283 bool operator < (const SSpriteBank& other) const
284 {
285 return (NamedPath < other.NamedPath);
286 }
287 };
288
289 struct SToolTip
290 {
291 IGUIStaticText* Element;
292 u32 LastTime;
293 u32 EnterTime;
294 u32 LaunchTime;
295 u32 RelaunchTime;
296 };
297
298 SToolTip ToolTip;
299
300 core::array<IGUIElementFactory*> GUIElementFactoryList;
301
302 core::array<SFont> Fonts;
303 core::array<SSpriteBank> Banks;
304 video::IVideoDriver* Driver;
305 IGUIElement* Hovered;
306 IGUIElement* HoveredNoSubelement; // subelements replaced by their parent, so you only have 'real' elements here
307 IGUIElement* Focus;
308 core::position2d<s32> LastHoveredMousePos;
309 IGUISkin* CurrentSkin;
310 io::IFileSystem* FileSystem;
311 IEventReceiver* UserReceiver;
312 IOSOperator* Operator;
313 static const io::path DefaultFontName;
314};
315
316} // end namespace gui
317} // end namespace irr
318
319#endif // _IRR_COMPILE_WITH_GUI_
320
321#endif // __C_GUI_ENVIRONMENT_H_INCLUDED__
322
323