ScummVM API documentation
GuiSet.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_GUI_SET_H
29 #define HPL_GUI_SET_H
30 
31 #include "common/list.h"
32 #include "hpl1/engine/graphics/GraphicsTypes.h"
33 #include "hpl1/engine/gui/GuiTypes.h"
34 #include "hpl1/std/multiset.h"
35 #include "hpl1/std/set.h"
36 
37 namespace hpl {
38 
39 //---------------------------------------------
40 
41 class cResources;
42 class cGraphics;
43 class cSound;
44 class cScene;
45 
46 class FontData;
47 
48 class cGui;
49 class cGuiSkin;
50 class iGuiMaterial;
51 class iGuiPopUp;
52 class iWidget;
53 
54 class cWidgetWindow;
55 class cWidgetFrame;
56 class cWidgetButton;
57 class cWidgetLabel;
58 class cWidgetSlider;
59 class cWidgetTextBox;
60 class cWidgetCheckBox;
61 class cWidgetImage;
62 class cWidgetListBox;
63 class cWidgetComboBox;
64 
65 //---------------------------------------------
66 
67 typedef Common::List<iGuiPopUp *> tGuiPopUpList;
68 typedef tGuiPopUpList::iterator tGuiPopUpListIt;
69 
70 //---------------------------------------------
71 
72 class cGuiClipRegion;
74 public:
75  cGuiGfxElement *mpGfx;
76  cVector3f mvPos;
77  cVector2f mvSize;
78  cColor mColor;
79  iGuiMaterial *mpCustomMaterial;
80  cGuiClipRegion *mpClipRegion;
81 };
82 
84 public:
85  bool operator()(const cGuiRenderObject &aObjectA, const cGuiRenderObject &aObjectB) const;
86 };
87 
89 typedef tGuiRenderObjectSet::iterator tGuiRenderObjectSetIt;
90 
91 //-----------------------------------------------
92 
95 
97 public:
98  cGuiClipRegion() : mRect(0, 0, -1, -1) {}
99  ~cGuiClipRegion();
100 
101  void Clear();
102  cGuiClipRegion *CreateChild(const cVector3f &avPos, const cVector2f &avSize);
103 
104  // tGuiRenderObjectSet m_setObjects;
105  cRect2f mRect;
106 
107  tGuiClipRegionList mlstChildren;
108 };
109 
110 //-----------------------------------------------
111 
112 class cGuiSet {
113 public:
114  cGuiSet(const tString &asName, cGui *apGui, cGuiSkin *apSkin,
115  cResources *apResources, cGraphics *apGraphics,
116  cSound *apSound, cScene *apScene);
117  ~cGuiSet();
118 
120  // General
121 
122  void Update(float afTimeStep);
123 
124  void DrawAll(float afTimeStep);
125 
126  bool SendMessage(eGuiMessage aMessage, cGuiMessageData &aData);
127 
129  // Rendering
130  void Render();
131 
132  void SetDrawOffset(const cVector3f &avOffset) { mvDrawOffset = avOffset; }
133  void SetCurrentClipRegion(cGuiClipRegion *apRegion) { mpCurrentClipRegion = apRegion; }
134 
135  void DrawGfx(cGuiGfxElement *apGfx,
136  const cVector3f &avPos,
137  const cVector2f &avSize = -1,
138  const cColor &aColor = cColor(1, 1),
139  eGuiMaterial aMaterial = eGuiMaterial_LastEnum);
140  void DrawFont(const tWString &asText,
141  FontData *apFont, const cVector3f &avPos,
142  const cVector2f &avSize, const cColor &aColor,
143  eFontAlign aAlign = eFontAlign_Left,
144  eGuiMaterial aMaterial = eGuiMaterial_FontNormal);
145 
147  // Widget Creation
148  cWidgetWindow *CreateWidgetWindow(const cVector3f &avLocalPos = 0,
149  const cVector2f &avSize = 0,
150  const tWString &asText = {},
151  iWidget *apParent = NULL,
152  const tString &asName = "");
153 
154  cWidgetFrame *CreateWidgetFrame(const cVector3f &avLocalPos = 0,
155  const cVector2f &avSize = 0,
156  bool abDrawFrame = false,
157  iWidget *apParent = NULL,
158  const tString &asName = "");
159 
160  cWidgetButton *CreateWidgetButton(const cVector3f &avLocalPos = 0,
161  const cVector2f &avSize = 0,
162  const tWString &asText = {},
163  iWidget *apParent = NULL,
164  const tString &asName = "");
165 
166  cWidgetLabel *CreateWidgetLabel(const cVector3f &avLocalPos = 0,
167  const cVector2f &avSize = 0,
168  const tWString &asText = {},
169  iWidget *apParent = NULL,
170  const tString &asName = "");
171 
172  cWidgetSlider *CreateWidgetSlider(eWidgetSliderOrientation aOrientation,
173  const cVector3f &avLocalPos = 0,
174  const cVector2f &avSize = 0,
175  int alMaxValue = 10,
176  iWidget *apParent = NULL,
177  const tString &asName = "");
178 
179  cWidgetTextBox *CreateWidgetTextBox(const cVector3f &avLocalPos = 0,
180  const cVector2f &avSize = 0,
181  const tWString &asText = {},
182  iWidget *apParent = NULL,
183  const tString &asName = "");
184 
185  cWidgetCheckBox *CreateWidgetCheckBox(const cVector3f &avLocalPos = 0,
186  const cVector2f &avSize = 0,
187  const tWString &asText = {},
188  iWidget *apParent = NULL,
189  const tString &asName = "");
190 
191  cWidgetImage *CreateWidgetImage(const tString &asFile = "",
192  const cVector3f &avLocalPos = 0,
193  const cVector2f &avSize = -1,
194  eGuiMaterial aMaterial = eGuiMaterial_Alpha,
195  bool abAnimate = false,
196  iWidget *apParent = NULL,
197  const tString &asName = "");
198 
199  cWidgetListBox *CreateWidgetListBox(const cVector3f &avLocalPos = 0,
200  const cVector2f &avSize = 0,
201  iWidget *apParent = NULL,
202  const tString &asName = "");
203 
204  cWidgetComboBox *CreateWidgetComboBox(const cVector3f &avLocalPos = 0,
205  const cVector2f &avSize = 0,
206  const tWString &asText = {},
207  iWidget *apParent = NULL,
208  const tString &asName = "");
209 
210  iWidget *GetWidgetFromName(const tString &asName);
211 
212  void DestroyWidget(iWidget *apWidget);
213 
215  // Popup
216  void CreatePopUpMessageBox(const tWString &asLabel, const tWString &asText,
217  const tWString &asButton1, const tWString &asButton2,
218  void *apCallbackObject, tGuiCallbackFunc apCallback);
219 
220  void DestroyPopUp(iGuiPopUp *apPopUp);
221 
223  // Properties
224  void SetActive(bool abX);
225  bool IsActive() { return mbActive; }
226 
227  cGui *GetGui() { return mpGui; }
228 
229  void SetDrawMouse(bool abX);
230  bool GetDrawMouse() { return mbDrawMouse; }
231 
232  void SetMouseZ(float afZ) { mfMouseZ = afZ; }
233  float GetMouse() { return mfMouseZ; }
234 
235  void SetRootWidgetClips(bool abX);
236  bool GetRootWidgetClips();
237 
238  void SetVirtualSize(const cVector2f &avSize, float afMinZ, float afMaxZ);
239  const cVector2f &GetVirtualSize() { return mvVirtualSize; }
240 
241  void SetFocusedWidget(iWidget *apWidget);
242  iWidget *GetFocusedWidget() { return mpFocusedWidget; }
243 
244  void SetAttentionWidget(iWidget *apWidget);
245  iWidget *GetAttentionWidget() { return mpAttentionWidget; }
246 
247  void SetIs3D(bool abX);
248  bool Is3D() { return mbIs3D; }
249 
250  int GetDrawPriority() { return mlDrawPrio; }
251  void SetDrawPriority(int alPrio) { mlDrawPrio = alPrio; }
252 
253  void SetCurrentPointer(cGuiGfxElement *apGfx);
254  cGuiGfxElement *GetCurrentPointer() { return mpGfxCurrentPointer; }
255 
256  void Set3DSize(const cVector3f &avSize);
257  cVector3f Get3DSize() { return mv3DSize; }
258 
259  void SetCullBackface(bool abX) { mbCullBackface = abX; }
260  bool GetCullBackface() { return mbCullBackface; }
261 
262  void Set3DTransform(const cMatrixf &a_mtxTransform);
263  cMatrixf Get3DTransform() { return m_mtx3DTransform; }
264 
265  bool HasFocus();
266 
267  void SetSkin(cGuiSkin *apSkin);
268  cGuiSkin *GetSkin() { return mpSkin; }
269 
270  cResources *GetResources() { return mpResources; }
271 
272  bool IsDestroyingSet() { return mbDestroyingSet; }
273 
274 private:
275  void RenderClipRegion();
276 
277  void AddWidget(iWidget *apWidget, iWidget *apParent);
278 
279  bool OnMouseMove(cGuiMessageData &aData);
280  bool OnMouseDown(cGuiMessageData &aData);
281  bool OnMouseUp(cGuiMessageData &aData);
282  bool OnMouseDoubleClick(cGuiMessageData &aData);
283 
284  bool OnKeyPress(cGuiMessageData &aData);
285 
286  bool DrawMouse(iWidget *apWidget, cGuiMessageData &aData);
287  kGuiCalllbackDeclarationEnd(DrawMouse);
288 
289  cGui *mpGui;
290  cGuiSkin *mpSkin;
291 
292  tString msName;
293 
294  cResources *mpResources;
295  cGraphics *mpGraphics;
296  cSound *mpSound;
297  cScene *mpScene;
298 
299  iWidget *mpAttentionWidget;
300 
301  iWidget *mpFocusedWidget;
302 
303  iWidget *mpWidgetRoot;
304  tWidgetList mlstWidgets;
305 
306  tGuiRenderObjectSet m_setRenderObjects;
307 
308  cVector2f mvVirtualSize;
309  float mfVirtualMinZ;
310  float mfVirtualMaxZ;
311 
312  cVector3f mvDrawOffset;
313 
314  bool mbCullBackface;
315  bool mbIs3D;
316  cVector3f mv3DSize;
317  cMatrixf m_mtx3DTransform;
318  int mlDrawPrio;
319 
320  bool mbActive;
321  bool mbDrawMouse;
322  float mfMouseZ;
323  cGuiGfxElement *mpGfxCurrentPointer;
324 
325  bool mvMouseDown[3];
326  cVector2f mvMousePos;
327 
328  tGuiPopUpList mlstPopUps;
329 
330  cGuiClipRegion mBaseClipRegion;
331  cGuiClipRegion *mpCurrentClipRegion;
332 
333  bool mbDestroyingSet;
334 };
335 
336 } // namespace hpl
337 
338 #endif // HPL_GUI_SET_H
Definition: AI.h:36
Definition: WidgetTextBox.h:37
Definition: Gui.h:73
Definition: GuiGfxElement.h:72
Definition: str.h:59
Definition: font_data.h:67
Definition: WidgetListBox.h:40
Definition: GuiPopUp.h:38
Definition: GuiTypes.h:263
Definition: WidgetWindow.h:39
Definition: WidgetCheckBox.h:37
Definition: WidgetFrame.h:37
Definition: Sound.h:40
Definition: ustr.h:57
Definition: Widget.h:65
Definition: WidgetSlider.h:41
Definition: GuiSet.h:112
Definition: GuiSet.h:96
Definition: WidgetButton.h:37
ListInternal::Iterator< t_T > iterator
Definition: list.h:52
Definition: GuiSkin.h:59
Definition: WidgetComboBox.h:42
Definition: Resources.h:160
Definition: Color.h:37
Definition: list_intern.h:51
Definition: Scene.h:61
Definition: WidgetImage.h:37
Definition: GuiMaterial.h:36
Definition: WidgetLabel.h:37
Definition: GuiSet.h:73
Definition: Graphics.h:46
Definition: GuiSet.h:83