Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSInterface_IGUIObject.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2013 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. 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 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. 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 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "precompiled.h"
19 
20 #include "JSInterface_IGUIObject.h"
21 #include "JSInterface_GUITypes.h"
22 
23 #include "gui/IGUIObject.h"
24 #include "gui/CGUI.h"
25 #include "gui/IGUIScrollBar.h"
26 #include "gui/CList.h"
27 #include "gui/GUIManager.h"
28 
29 #include "ps/CLogger.h"
30 
32 
34  "GUIObject", JSCLASS_HAS_PRIVATE,
35  JS_PropertyStub, JS_PropertyStub,
37  JS_EnumerateStub, JS_ResolveStub,
38  JS_ConvertStub, JS_FinalizeStub,
39  NULL, NULL, NULL, JSI_IGUIObject::construct
40 };
41 
42 JSPropertySpec JSI_IGUIObject::JSI_props[] =
43 {
44  { 0 }
45 };
46 
47 JSFunctionSpec JSI_IGUIObject::JSI_methods[] =
48 {
49  { "toString", JSI_IGUIObject::toString, 0, 0 },
50  { "focus", JSI_IGUIObject::focus, 0, 0 },
51  { "blur", JSI_IGUIObject::blur, 0, 0 },
52  { "getComputedSize", JSI_IGUIObject::getComputedSize, 0, 0 },
53  { 0 }
54 };
55 
56 JSBool JSI_IGUIObject::getProperty(JSContext* cx, JSObject* obj, jsid id, jsval* vp)
57 {
58  IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, obj, &JSI_IGUIObject::JSI_class, NULL);
59  if (!e)
60  return JS_FALSE;
61 
62  jsval idval;
63  if (!JS_IdToValue(cx, id, &idval))
64  return JS_FALSE;
65 
66  std::string propName;
67  if (!ScriptInterface::FromJSVal(cx, idval, propName))
68  return JS_FALSE;
69 
70  // Skip some things which are known to be functions rather than properties.
71  // ("constructor" *must* be here, else it'll try to GetSettingType before
72  // the private IGUIObject* has been set (and thus crash). The others are
73  // partly for efficiency, and also to allow correct reporting of attempts to
74  // access nonexistent properties.)
75  if (propName == "constructor" ||
76  propName == "prototype" ||
77  propName == "toString" ||
78  propName == "toJSON" ||
79  propName == "focus" ||
80  propName == "blur" ||
81  propName == "getComputedSize"
82  )
83  return JS_TRUE;
84 
85  // Use onWhatever to access event handlers
86  if (propName.substr(0, 2) == "on")
87  {
88  CStr eventName (CStr(propName.substr(2)).LowerCase());
89  std::map<CStr, JSObject**>::iterator it = e->m_ScriptHandlers.find(eventName);
90  if (it == e->m_ScriptHandlers.end())
91  *vp = JSVAL_NULL;
92  else
93  *vp = OBJECT_TO_JSVAL(*(it->second));
94  return JS_TRUE;
95  }
96 
97 
98  // Handle the "parent" property specially
99  if (propName == "parent")
100  {
101  IGUIObject* parent = e->GetParent();
102  if (parent)
103  {
104  // If the object isn't parentless, return a new object
105  *vp = OBJECT_TO_JSVAL(parent->GetJSObject());
106  }
107  else
108  {
109  // Return null if there's no parent
110  *vp = JSVAL_NULL;
111  }
112  return JS_TRUE;
113  }
114  // Also handle "name" specially
115  else if (propName == "name")
116  {
117  *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, e->GetName().c_str()));
118  return JS_TRUE;
119  }
120  // Handle all other properties
121  else
122  {
123  // Retrieve the setting's type (and make sure it actually exists)
124  EGUISettingType Type;
125  if (e->GetSettingType(propName, Type) != PSRETURN_OK)
126  {
127  JS_ReportError(cx, "Invalid GUIObject property '%s'", propName.c_str());
128  return JS_FALSE;
129  }
130 
131  // (All the cases are in {...} to avoid scoping problems)
132  switch (Type)
133  {
134  case GUIST_bool:
135  {
136  bool value;
137  GUI<bool>::GetSetting(e, propName, value);
138  *vp = value ? JSVAL_TRUE : JSVAL_FALSE;
139  break;
140  }
141 
142  case GUIST_int:
143  {
144  int value;
145  GUI<int>::GetSetting(e, propName, value);
146  *vp = INT_TO_JSVAL(value);
147  break;
148  }
149 
150  case GUIST_float:
151  {
152  float value;
153  GUI<float>::GetSetting(e, propName, value);
154  // Create a garbage-collectable double
155  return JS_NewNumberValue(cx, value, vp);
156  }
157 
158  case GUIST_CColor:
159  {
160  CColor colour;
161  GUI<CColor>::GetSetting(e, propName, colour);
162  JSObject* obj = JS_NewObject(cx, &JSI_GUIColor::JSI_class, NULL, NULL);
163  *vp = OBJECT_TO_JSVAL(obj); // root it
164 
165  jsval c;
166  // Attempt to minimise ugliness through macrosity
167  #define P(x) if (!JS_NewNumberValue(cx, colour.x, &c)) return JS_FALSE; JS_SetProperty(cx, obj, #x, &c)
168  P(r);
169  P(g);
170  P(b);
171  P(a);
172  #undef P
173 
174  break;
175  }
176 
177  case GUIST_CClientArea:
178  {
179  CClientArea area;
180  GUI<CClientArea>::GetSetting(e, propName, area);
181  JSObject* obj = JS_NewObject(cx, &JSI_GUISize::JSI_class, NULL, NULL);
182  *vp = OBJECT_TO_JSVAL(obj); // root it
183  try
184  {
185  #define P(x, y, z) g_ScriptingHost.SetObjectProperty_Double(obj, #z, area.x.y)
186  P(pixel, left, left);
187  P(pixel, top, top);
188  P(pixel, right, right);
189  P(pixel, bottom, bottom);
190  P(percent, left, rleft);
191  P(percent, top, rtop);
192  P(percent, right, rright);
193  P(percent, bottom, rbottom);
194  #undef P
195  }
197  {
198  debug_warn(L"Error creating size object!");
199  break;
200  }
201 
202  break;
203  }
204 
205  case GUIST_CGUIString:
206  {
207  CGUIString value;
208  GUI<CGUIString>::GetSetting(e, propName, value);
209  *vp = ScriptInterface::ToJSVal(cx, value.GetOriginalString());
210  break;
211  }
212 
213  case GUIST_CStr:
214  {
215  CStr value;
216  GUI<CStr>::GetSetting(e, propName, value);
217  *vp = ScriptInterface::ToJSVal(cx, value);
218  break;
219  }
220 
221  case GUIST_CStrW:
222  {
223  CStrW value;
224  GUI<CStrW>::GetSetting(e, propName, value);
225  *vp = ScriptInterface::ToJSVal(cx, value);
226  break;
227  }
228 
229  case GUIST_CGUISpriteInstance:
230  {
231  CGUISpriteInstance *value;
232  GUI<CGUISpriteInstance>::GetSettingPointer(e, propName, value);
233  *vp = ScriptInterface::ToJSVal(cx, value->GetName());
234  break;
235  }
236 
237  case GUIST_EAlign:
238  {
239  EAlign value;
240  GUI<EAlign>::GetSetting(e, propName, value);
241  CStr word;
242  switch (value)
243  {
244  case EAlign_Left: word = "left"; break;
245  case EAlign_Right: word = "right"; break;
246  case EAlign_Center: word = "center"; break;
247  default: debug_warn(L"Invalid EAlign!"); word = "error"; break;
248  }
249  *vp = ScriptInterface::ToJSVal(cx, word);
250  break;
251  }
252 
253  case GUIST_EVAlign:
254  {
255  EVAlign value;
256  GUI<EVAlign>::GetSetting(e, propName, value);
257  CStr word;
258  switch (value)
259  {
260  case EVAlign_Top: word = "top"; break;
261  case EVAlign_Bottom: word = "bottom"; break;
262  case EVAlign_Center: word = "center"; break;
263  default: debug_warn(L"Invalid EVAlign!"); word = "error"; break;
264  }
265  *vp = ScriptInterface::ToJSVal(cx, word);
266  break;
267  }
268 
269  case GUIST_CGUIList:
270  {
271  CGUIList value;
272  GUI<CGUIList>::GetSetting(e, propName, value);
273 
274  JSObject *obj = JS_NewArrayObject(cx, 0, NULL);
275  *vp = OBJECT_TO_JSVAL(obj); // root it
276 
277  for (size_t i = 0; i < value.m_Items.size(); ++i)
278  {
279  jsval val = ScriptInterface::ToJSVal(cx, value.m_Items[i].GetOriginalString());
280  JS_SetElement(cx, obj, (jsint)i, &val);
281  }
282 
283  break;
284  }
285 
286  default:
287  JS_ReportError(cx, "Setting '%s' uses an unimplemented type", propName.c_str());
289  return JS_FALSE;
290  }
291 
292  return JS_TRUE;
293  }
294 }
295 
296 JSBool JSI_IGUIObject::setProperty(JSContext* cx, JSObject* obj, jsid id, JSBool UNUSED(strict), jsval* vp)
297 {
298  IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, obj, &JSI_IGUIObject::JSI_class, NULL);
299  if (!e)
300  return JS_FALSE;
301 
302  jsval idval;
303  if (!JS_IdToValue(cx, id, &idval))
304  return JS_FALSE;
305 
306  std::string propName;
307  if (!ScriptInterface::FromJSVal(cx, idval, propName))
308  return JS_FALSE;
309 
310  if (propName == "name")
311  {
312  std::string value;
313  if (!ScriptInterface::FromJSVal(cx, *vp, value))
314  return JS_FALSE;
315  e->SetName(value);
316  return JS_TRUE;
317  }
318 
319  // Use onWhatever to set event handlers
320  if (propName.substr(0, 2) == "on")
321  {
322  if (!JSVAL_IS_OBJECT(*vp) || !JS_ObjectIsFunction(cx, JSVAL_TO_OBJECT(*vp)))
323  {
324  JS_ReportError(cx, "on- event-handlers must be functions");
325  return JS_FALSE;
326  }
327 
328  CStr eventName (CStr(propName.substr(2)).LowerCase());
329  e->SetScriptHandler(eventName, JSVAL_TO_OBJECT(*vp));
330 
331  return JS_TRUE;
332  }
333 
334  // Retrieve the setting's type (and make sure it actually exists)
335  EGUISettingType Type;
336  if (e->GetSettingType(propName, Type) != PSRETURN_OK)
337  {
338  JS_ReportError(cx, "Invalid setting '%s'", propName.c_str());
339  return JS_TRUE;
340  }
341 
342  switch (Type)
343  {
344 
345  case GUIST_CStr:
346  {
347  std::string value;
348  if (!ScriptInterface::FromJSVal(cx, *vp, value))
349  return JS_FALSE;
350 
351  GUI<CStr>::SetSetting(e, propName, value);
352  break;
353  }
354 
355  case GUIST_CStrW:
356  {
357  std::wstring value;
358  if (!ScriptInterface::FromJSVal(cx, *vp, value))
359  return JS_FALSE;
360 
361  GUI<CStrW>::SetSetting(e, propName, value);
362  break;
363  }
364 
365  case GUIST_CGUISpriteInstance:
366  {
367  std::string value;
368  if (!ScriptInterface::FromJSVal(cx, *vp, value))
369  return JS_FALSE;
370 
372  break;
373  }
374 
375  case GUIST_CGUIString:
376  {
377  std::wstring value;
378  if (!ScriptInterface::FromJSVal(cx, *vp, value))
379  return JS_FALSE;
380 
381  CGUIString str;
382  str.SetValue(value);
383  GUI<CGUIString>::SetSetting(e, propName, str);
384  break;
385  }
386 
387  case GUIST_EAlign:
388  {
389  std::string value;
390  if (!ScriptInterface::FromJSVal(cx, *vp, value))
391  return JS_FALSE;
392 
393  EAlign a;
394  if (value == "left") a = EAlign_Left;
395  else if (value == "right") a = EAlign_Right;
396  else if (value == "center" || value == "centre") a = EAlign_Center;
397  else
398  {
399  JS_ReportError(cx, "Invalid alignment (should be 'left', 'right' or 'center')");
400  return JS_FALSE;
401  }
402  GUI<EAlign>::SetSetting(e, propName, a);
403  break;
404  }
405 
406  case GUIST_EVAlign:
407  {
408  std::string value;
409  if (!ScriptInterface::FromJSVal(cx, *vp, value))
410  return JS_FALSE;
411 
412  EVAlign a;
413  if (value == "top") a = EVAlign_Top;
414  else if (value == "bottom") a = EVAlign_Bottom;
415  else if (value == "center" || value == "centre") a = EVAlign_Center;
416  else
417  {
418  JS_ReportError(cx, "Invalid alignment (should be 'top', 'bottom' or 'center')");
419  return JS_FALSE;
420  }
421  GUI<EVAlign>::SetSetting(e, propName, a);
422  break;
423  }
424 
425  case GUIST_int:
426  {
427  int32 value;
428  if (JS_ValueToInt32(cx, *vp, &value) == JS_TRUE)
429  GUI<int>::SetSetting(e, propName, value);
430  else
431  {
432  JS_ReportError(cx, "Cannot convert value to int");
433  return JS_FALSE;
434  }
435  break;
436  }
437 
438  case GUIST_float:
439  {
440  jsdouble value;
441  if (JS_ValueToNumber(cx, *vp, &value) == JS_TRUE)
442  GUI<float>::SetSetting(e, propName, (float)value);
443  else
444  {
445  JS_ReportError(cx, "Cannot convert value to float");
446  return JS_FALSE;
447  }
448  break;
449  }
450 
451  case GUIST_bool:
452  {
453  JSBool value;
454  if (JS_ValueToBoolean(cx, *vp, &value) == JS_TRUE)
455  GUI<bool>::SetSetting(e, propName, value == JS_TRUE);
456  else
457  {
458  JS_ReportError(cx, "Cannot convert value to bool");
459  return JS_FALSE;
460  }
461  break;
462  }
463 
464  case GUIST_CClientArea:
465  {
466  if (JSVAL_IS_STRING(*vp))
467  {
468  std::wstring value;
469  if (!ScriptInterface::FromJSVal(cx, *vp, value))
470  return JS_FALSE;
471 
472  if (e->SetSetting(propName, value) != PSRETURN_OK)
473  {
474  JS_ReportError(cx, "Invalid value for setting '%s'", propName.c_str());
475  return JS_FALSE;
476  }
477  }
478  else if (JSVAL_IS_OBJECT(*vp) && JS_InstanceOf(cx, JSVAL_TO_OBJECT(*vp), &JSI_GUISize::JSI_class, NULL))
479  {
480  CClientArea area;
481  GUI<CClientArea>::GetSetting(e, propName, area);
482 
483  JSObject* obj = JSVAL_TO_OBJECT(*vp);
484  #define P(x, y, z) area.x.y = (float)g_ScriptingHost.GetObjectProperty_Double(obj, #z)
485  P(pixel, left, left);
486  P(pixel, top, top);
487  P(pixel, right, right);
488  P(pixel, bottom, bottom);
489  P(percent, left, rleft);
490  P(percent, top, rtop);
491  P(percent, right, rright);
492  P(percent, bottom, rbottom);
493  #undef P
494 
495  GUI<CClientArea>::SetSetting(e, propName, area);
496  }
497  else
498  {
499  JS_ReportError(cx, "Size only accepts strings or GUISize objects");
500  return JS_FALSE;
501  }
502  break;
503  }
504 
505  case GUIST_CColor:
506  {
507  if (JSVAL_IS_STRING(*vp))
508  {
509  std::wstring value;
510  if (!ScriptInterface::FromJSVal(cx, *vp, value))
511  return JS_FALSE;
512 
513  if (e->SetSetting(propName, value) != PSRETURN_OK)
514  {
515  JS_ReportError(cx, "Invalid value for setting '%s'", propName.c_str());
516  return JS_FALSE;
517  }
518  }
519  else if (JSVAL_IS_OBJECT(*vp) && JS_InstanceOf(cx, JSVAL_TO_OBJECT(*vp), &JSI_GUIColor::JSI_class, NULL))
520  {
521  CColor colour;
522  JSObject* obj = JSVAL_TO_OBJECT(*vp);
523  jsval t; double s;
524  #define PROP(x) JS_GetProperty(cx, obj, #x, &t); \
525  JS_ValueToNumber(cx, t, &s); \
526  colour.x = (float)s
527  PROP(r); PROP(g); PROP(b); PROP(a);
528  #undef PROP
529 
530  GUI<CColor>::SetSetting(e, propName, colour);
531  }
532  else
533  {
534  JS_ReportError(cx, "Color only accepts strings or GUIColor objects");
535  return JS_FALSE;
536  }
537  break;
538  }
539 
540  case GUIST_CGUIList:
541  {
542  JSObject* obj = JSVAL_TO_OBJECT(*vp);
543  jsuint length;
544  if (JSVAL_IS_OBJECT(*vp) && JS_GetArrayLength(cx, obj, &length) == JS_TRUE)
545  {
546  CGUIList list;
547 
548  for (int i=0; i<(int)length; ++i)
549  {
550  jsval element;
551  if (! JS_GetElement(cx, obj, i, &element))
552  {
553  JS_ReportError(cx, "Failed to get list element");
554  return JS_FALSE;
555  }
556 
557  std::wstring value;
558  if (!ScriptInterface::FromJSVal(cx, element, value))
559  return JS_FALSE;
560 
561  CGUIString str;
562  str.SetValue(value);
563 
564  list.m_Items.push_back(str);
565  }
566 
567  GUI<CGUIList>::SetSetting(e, propName, list);
568  }
569  else
570  {
571  JS_ReportError(cx, "List only accepts a GUIList object");
572  return JS_FALSE;
573  }
574  break;
575  }
576 
577  // TODO Gee: (2004-09-01) EAlign and EVAlign too.
578 
579  default:
580  JS_ReportError(cx, "Setting '%s' uses an unimplemented type", propName.c_str());
581  break;
582  }
583 
584  return !JS_IsExceptionPending(cx);
585 }
586 
587 
588 JSBool JSI_IGUIObject::construct(JSContext* cx, uintN argc, jsval* vp)
589 {
590  if (argc == 0)
591  {
592  JS_ReportError(cx, "GUIObject has no default constructor");
593  return JS_FALSE;
594  }
595 
596  JSObject* obj = JS_NewObject(cx, &JSI_IGUIObject::JSI_class, NULL, NULL);
597 
598  // Store the IGUIObject in the JS object's 'private' area
599  IGUIObject* guiObject = (IGUIObject*)JSVAL_TO_PRIVATE(JS_ARGV(cx, vp)[0]);
600  JS_SetPrivate(cx, obj, guiObject);
601 
602  JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj));
603  return JS_TRUE;
604 }
605 
607 {
608  g_ScriptingHost.DefineCustomObjectType(&JSI_class, construct, 1, JSI_props, JSI_methods, NULL, NULL);
609 }
610 
611 JSBool JSI_IGUIObject::toString(JSContext* cx, uintN argc, jsval* vp)
612 {
613  UNUSED2(argc);
614 
615  IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx, vp), &JSI_IGUIObject::JSI_class, NULL);
616  if (!e)
617  return JS_FALSE;
618 
619  char buffer[256];
620  snprintf(buffer, 256, "[GUIObject: %s]", e->GetName().c_str());
621  buffer[255] = 0;
622  JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, buffer)));
623  return JS_TRUE;
624 }
625 
626 JSBool JSI_IGUIObject::focus(JSContext* cx, uintN argc, jsval* vp)
627 {
628  UNUSED2(argc);
629 
630  IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx, vp), &JSI_IGUIObject::JSI_class, NULL);
631  if (!e)
632  return JS_FALSE;
633 
634  e->GetGUI()->SetFocusedObject(e);
635 
636  JS_SET_RVAL(cx, vp, JSVAL_VOID);
637  return JS_TRUE;
638 }
639 
640 JSBool JSI_IGUIObject::blur(JSContext* cx, uintN argc, jsval* vp)
641 {
642  UNUSED2(argc);
643 
644  IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx, vp), &JSI_IGUIObject::JSI_class, NULL);
645  if (!e)
646  return JS_FALSE;
647 
648  e->GetGUI()->SetFocusedObject(NULL);
649 
650  JS_SET_RVAL(cx, vp, JSVAL_VOID);
651  return JS_TRUE;
652 }
653 
654 JSBool JSI_IGUIObject::getComputedSize(JSContext* cx, uintN argc, jsval* vp)
655 {
656  UNUSED2(argc);
657 
658  IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx, vp), &JSI_IGUIObject::JSI_class, NULL);
659  if (!e)
660  return JS_FALSE;
661 
662  e->UpdateCachedSize();
663  CRect size = e->m_CachedActualSize;
664 
665  JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
666  try
667  {
668  g_ScriptingHost.SetObjectProperty_Double(obj, "left", size.left);
669  g_ScriptingHost.SetObjectProperty_Double(obj, "right", size.right);
670  g_ScriptingHost.SetObjectProperty_Double(obj, "top", size.top);
671  g_ScriptingHost.SetObjectProperty_Double(obj, "bottom", size.bottom);
672  }
674  {
675  debug_warn(L"Error creating size object!");
676  return JS_FALSE;
677  }
678 
679  JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj));
680  return JS_TRUE;
681 }
JSPropertySpec JSI_props[]
const Status LOGIC
Definition: status.h:409
JSBool blur(JSContext *cx, uintN argc, jsval *vp)
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
JSFunctionSpec JSI_methods[]
void SetScriptHandler(const CStr &Action, JSObject *Function)
Definition: IGUIObject.cpp:452
const PSRETURN PSRETURN_OK
Definition: Errors.h:103
float top
Definition: Overlay.h:159
Definition: Overlay.h:34
JSBool getProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
float left
Returning CPos representing each corner.
Definition: Overlay.h:159
static PSRETURN GetSetting(const IGUIObject *pObject, const CStr &Setting, T &Value)
Retrieves a setting by name from object pointer.
Definition: GUIutil.cpp:344
#define PROP(x)
const CStr & GetName() const
Get object name, name is unique.
Definition: IGUIObject.h:181
EGUISettingType
Definition: IGUIObject.h:95
Base settings, all objects possess these settings in their m_BaseSettings Instructions can be found i...
Definition: IGUIObject.h:140
JSBool toString(JSContext *cx, uintN argc, jsval *vp)
static bool FromJSVal(JSContext *cx, jsval val, T &ret)
Convert a jsval to a C++ type.
virtual void UpdateCachedSize()
All sizes are relative to resolution, and the calculation is not wanted in real time, therefore it is cached, update the cached size with this function.
Definition: IGUIObject.cpp:336
JSObject * GetJSObject()
Retrieves the JSObject representing this GUI object.
Definition: IGUIObject.cpp:522
#define UNUSED2(param)
mark a function local variable or parameter as unused and avoid the corresponding compiler warning...
#define P(x)
IGUIObject * GetParent() const
NOTE! This will not just return m_pParent, when that is need use it! There is one exception to it...
Definition: IGUIObject.cpp:323
#define g_ScriptingHost
JSFunctionSpec JSI_methods[]
std::vector< CGUIString > m_Items
List of items (as text), the post-processed result is stored in the IGUITextOwner structure of this c...
Definition: CGUIList.h:33
static jsval ToJSVal(JSContext *cx, T const &val)
Convert a C++ type to a jsval.
JSBool setProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
void SetName(const CStr &Name)
Get object name.
Definition: IGUIObject.h:184
void SetValue(const CStrW &str)
Set the value, the string will automatically be parsed when set.
Definition: GUItext.cpp:303
CRect m_CachedActualSize
Cached size, real size m_Size is actually dependent on resolution and can have different real outcome...
Definition: IGUIObject.h:434
#define DEBUG_WARN_ERR(status)
display the error dialog with text corresponding to the given error code.
Definition: debug.h:331
JSBool construct(JSContext *cx, uintN argc, jsval *vp)
JSBool getComputedSize(JSContext *cx, uintN argc, jsval *vp)
PSRETURN GetSettingType(const CStr &Setting, EGUISettingType &Type) const
Retrieves the type of a named setting.
Definition: IGUIObject.cpp:285
float right
Definition: Overlay.h:159
CGUI * GetGUI()
Definition: IGUIObject.h:388
PSRETURN SetSetting(const CStr &Setting, const CStrW &Value, const bool &SkipMessage=false)
Set a setting by string, regardless of what type it is.
Definition: IGUIObject.cpp:260
static PSRETURN SetSetting(IGUIObject *pObject, const CStr &Setting, const T &Value, const bool &SkipMessage=false)
Sets a value by name using a real datatype as input.
Definition: GUIutil.cpp:366
const CStr & GetName()
Definition: CGUISprite.h:182
std::map< CStr, JSObject ** > m_ScriptHandlers
Definition: IGUIObject.h:557
#define debug_warn(expr)
display the error dialog with the given text.
Definition: debug.h:324
EAlign
Definition: GUIbase.h:150
JSBool focus(JSContext *cx, uintN argc, jsval *vp)
EVAlign
Definition: GUIbase.h:151
float bottom
Definition: Overlay.h:159
JSPropertySpec JSI_props[]
const CStrW & GetOriginalString() const
Get String, with tags.
Definition: GUItext.h:300
String class, substitute for CStr, but that parses the tags and builds up a list of all text that wil...
Definition: GUItext.h:176
JSBool construct(JSContext *cx, uintN argc, jsval *vp)
void SetFocusedObject(IGUIObject *pObject)
Change focus to new object.
Definition: CGUI.cpp:586
static PSRETURN GetSettingPointer(const IGUIObject *pObject, const CStr &Setting, T *&Value)
Definition: GUIutil.cpp:317
Rectangle class used for screen rectangles.
Definition: Overlay.h:71
Client Area is a rectangle relative to a parent rectangle.
Definition: GUIbase.h:179