]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CGUIEnvironment.h
Reduce IrrCompileConfig usage to files that actually need it
[irrlicht.git] / source / Irrlicht / CGUIEnvironment.h
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt\r
2 // This file is part of the "Irrlicht Engine".\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h\r
4 \r
5 #ifndef __C_GUI_ENVIRONMENT_H_INCLUDED__\r
6 #define __C_GUI_ENVIRONMENT_H_INCLUDED__\r
7 \r
8 #include "IGUIEnvironment.h"\r
9 #include "IGUIElement.h"\r
10 #include "irrArray.h"\r
11 #include "IFileSystem.h"\r
12 #include "IOSOperator.h"\r
13 \r
14 namespace irr\r
15 {\r
16 \r
17 namespace gui\r
18 {\r
19 \r
20 class CGUIEnvironment : public IGUIEnvironment, public IGUIElement\r
21 {\r
22 public:\r
23 \r
24         //! constructor\r
25         CGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* driver, IOSOperator* op);\r
26 \r
27         //! destructor\r
28         virtual ~CGUIEnvironment();\r
29 \r
30         //! draws all gui elements\r
31         void drawAll(bool useScreenSize) override;\r
32 \r
33         //! returns the current video driver\r
34         video::IVideoDriver* getVideoDriver() const override;\r
35 \r
36         //! returns pointer to the filesystem\r
37         io::IFileSystem* getFileSystem() const override;\r
38 \r
39         //! returns a pointer to the OS operator\r
40         IOSOperator* getOSOperator() const override;\r
41 \r
42         //! posts an input event to the environment\r
43         bool postEventFromUser(const SEvent& event) override;\r
44 \r
45         //! This sets a new event receiver for gui events. Usually you do not have to\r
46         //! use this method, it is used by the internal engine.\r
47         void setUserEventReceiver(IEventReceiver* evr) override;\r
48 \r
49         //! removes all elements from the environment\r
50         void clear() override;\r
51 \r
52         //! called if an event happened.\r
53         bool OnEvent(const SEvent& event) override;\r
54 \r
55         //! returns the current gui skin\r
56         IGUISkin* getSkin() const override;\r
57 \r
58         //! Sets a new GUI Skin\r
59         void setSkin(IGUISkin* skin) override;\r
60 \r
61         //! Creates a new GUI Skin based on a template.\r
62         /** \return Returns a pointer to the created skin.\r
63         If you no longer need the skin, you should call IGUISkin::drop().\r
64         See IReferenceCounted::drop() for more information. */\r
65         IGUISkin* createSkin(EGUI_SKIN_TYPE type) override;\r
66 \r
67         //! Creates the image list from the given texture.\r
68         virtual IGUIImageList* createImageList(video::ITexture* texture,\r
69                                         core::dimension2d<s32> imageSize, bool useAlphaChannel) override;\r
70 \r
71         //! returns the font\r
72         IGUIFont* getFont(const io::path& filename) override;\r
73 \r
74         //! add an externally loaded font\r
75         IGUIFont* addFont(const io::path& name, IGUIFont* font) override;\r
76 \r
77         //! remove loaded font\r
78         void removeFont(IGUIFont* font) override;\r
79 \r
80         //! returns default font\r
81         IGUIFont* getBuiltInFont() const override;\r
82 \r
83         //! returns the sprite bank\r
84         IGUISpriteBank* getSpriteBank(const io::path& filename) override;\r
85 \r
86         //! returns the sprite bank\r
87         IGUISpriteBank* addEmptySpriteBank(const io::path& name) override;\r
88 \r
89         //! adds an button. The returned pointer must not be dropped.\r
90         IGUIButton* addButton(const core::rect<s32>& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0,const wchar_t* tooltiptext = 0) override;\r
91 \r
92         //! adds a scrollbar. The returned pointer must not be dropped.\r
93         virtual IGUIScrollBar* addScrollBar(bool horizontal, const core::rect<s32>& rectangle,\r
94                 IGUIElement* parent=0, s32 id=-1) override;\r
95 \r
96         //! Adds an image element.\r
97         virtual IGUIImage* addImage(video::ITexture* image, core::position2d<s32> pos,\r
98                 bool useAlphaChannel=true, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) override;\r
99 \r
100         //! adds an image. The returned pointer must not be dropped.\r
101         virtual IGUIImage* addImage(const core::rect<s32>& rectangle,\r
102                 IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0, bool useAlphaChannel=true) override;\r
103 \r
104         //! adds a checkbox\r
105         virtual IGUICheckBox* addCheckBox(bool checked, const core::rect<s32>& rectangle,\r
106                 IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) override;\r
107 \r
108         //! adds a list box\r
109         virtual IGUIListBox* addListBox(const core::rect<s32>& rectangle,\r
110                 IGUIElement* parent=0, s32 id=-1, bool drawBackground=false) override;\r
111 \r
112         //! Adds a file open dialog.\r
113         virtual IGUIFileOpenDialog* addFileOpenDialog(const wchar_t* title = 0,\r
114                         bool modal=true, IGUIElement* parent=0, s32 id=-1,\r
115                         bool restoreCWD=false, io::path::char_type* startDir=0) override;\r
116 \r
117         //! adds a static text. The returned pointer must not be dropped.\r
118         virtual IGUIStaticText* addStaticText(const wchar_t* text, const core::rect<s32>& rectangle,\r
119                 bool border=false, bool wordWrap=true, IGUIElement* parent=0, s32 id=-1, bool drawBackground = false) override;\r
120 \r
121         //! Adds an edit box. The returned pointer must not be dropped.\r
122         virtual IGUIEditBox* addEditBox(const wchar_t* text, const core::rect<s32>& rectangle,\r
123                 bool border=false, IGUIElement* parent=0, s32 id=-1) override;\r
124 \r
125         //! Adds a tab control to the environment.\r
126         virtual IGUITabControl* addTabControl(const core::rect<s32>& rectangle,\r
127                 IGUIElement* parent=0, bool fillbackground=false, bool border=true, s32 id=-1) override;\r
128 \r
129         //! Adds tab to the environment.\r
130         virtual IGUITab* addTab(const core::rect<s32>& rectangle,\r
131                 IGUIElement* parent=0, s32 id=-1) override;\r
132 \r
133         //! Adds a combo box to the environment.\r
134         virtual IGUIComboBox* addComboBox(const core::rect<s32>& rectangle,\r
135                 IGUIElement* parent=0, s32 id=-1) override;\r
136 \r
137         //! sets the focus to an element\r
138         bool setFocus(IGUIElement* element) override;\r
139 \r
140         //! removes the focus from an element\r
141         bool removeFocus(IGUIElement* element) override;\r
142 \r
143         //! Returns if the element has focus\r
144         bool hasFocus(const IGUIElement* element, bool checkSubElements=false) const override;\r
145 \r
146         //! Returns the element with the focus\r
147         IGUIElement* getFocus() const override;\r
148 \r
149         //! Returns the element last known to be under the mouse\r
150         IGUIElement* getHovered() const override;\r
151 \r
152         //! Returns the root gui element.\r
153         IGUIElement* getRootGUIElement() override;\r
154 \r
155         void OnPostRender( u32 time ) override;\r
156 \r
157         //! Find the next element which would be selected when pressing the tab-key\r
158         IGUIElement* getNextElement(bool reverse=false, bool group=false) override;\r
159 \r
160         //! Set the way the gui will handle focus changes\r
161         void setFocusBehavior(u32 flags) override;\r
162 \r
163         //! Get the way the gui does handle focus changes\r
164         u32 getFocusBehavior() const override;\r
165 \r
166         //! Adds a IGUIElement to deletion queue.\r
167         void addToDeletionQueue(IGUIElement* element) override;\r
168 \r
169 private:\r
170 \r
171         //! clears the deletion queue\r
172         void clearDeletionQueue();\r
173 \r
174         void updateHoveredElement(core::position2d<s32> mousePos);\r
175 \r
176         void loadBuiltInFont();\r
177 \r
178         struct SFont\r
179         {\r
180                 io::SNamedPath NamedPath;\r
181                 IGUIFont* Font;\r
182 \r
183                 bool operator < (const SFont& other) const\r
184                 {\r
185                         return (NamedPath < other.NamedPath);\r
186                 }\r
187         };\r
188 \r
189         struct SSpriteBank\r
190         {\r
191                 io::SNamedPath NamedPath;\r
192                 IGUISpriteBank* Bank;\r
193 \r
194                 bool operator < (const SSpriteBank& other) const\r
195                 {\r
196                         return (NamedPath < other.NamedPath);\r
197                 }\r
198         };\r
199 \r
200         struct SToolTip\r
201         {\r
202                 IGUIStaticText* Element;\r
203                 u32 LastTime;\r
204                 u32 EnterTime;\r
205                 u32 LaunchTime;\r
206                 u32 RelaunchTime;\r
207         };\r
208 \r
209         SToolTip ToolTip;\r
210 \r
211         core::array<SFont> Fonts;\r
212         core::array<SSpriteBank> Banks;\r
213         video::IVideoDriver* Driver;\r
214         IGUIElement* Hovered;\r
215         IGUIElement* HoveredNoSubelement;       // subelements replaced by their parent, so you only have 'real' elements here\r
216         IGUIElement* Focus;\r
217         core::position2d<s32> LastHoveredMousePos;\r
218         IGUISkin* CurrentSkin;\r
219         io::IFileSystem* FileSystem;\r
220         IEventReceiver* UserReceiver;\r
221         IOSOperator* Operator;\r
222         u32 FocusFlags;\r
223         core::array<IGUIElement*> DeletionQueue;\r
224 \r
225         static const io::path DefaultFontName;\r
226 };\r
227 \r
228 } // end namespace gui\r
229 } // end namespace irr\r
230 \r
231 #endif // __C_GUI_ENVIRONMENT_H_INCLUDED__\r