1
0

xuistatus.cpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #include <precomp.h>
  2. #include "xuistatus.h"
  3. const wchar_t StatusXuiObjectStr[] = L"LayoutStatus"; // This is the xml tag
  4. char StatusXuiSvcName[] = "Status xui object";
  5. LayoutStatusController _layoutStatusController;
  6. LayoutStatusController *layoutStatusController = &_layoutStatusController;
  7. XMLParamPair XuiStatus::params[] = {
  8. {EXCLUDE, L"EXCLUDE"},
  9. {INCLUDE, L"INCLUDEONLY"},
  10. };
  11. XuiStatus::XuiStatus() {
  12. getScriptObject()->vcpu_setInterface(layoutStatusGuid, (void *)static_cast<XuiStatus *>(this));
  13. getScriptObject()->vcpu_setClassName(L"LayoutStatus"); // this is the script class name
  14. getScriptObject()->vcpu_setController(layoutStatusController);
  15. myxuihandle = newXuiHandle();
  16. CreateXMLParameters(myxuihandle);
  17. }
  18. void XuiStatus::CreateXMLParameters(int master_handle)
  19. {
  20. //XUISTATUS_PARENT::CreateXMLParameters(master_handle);
  21. int numParams = sizeof(params) / sizeof(params[0]);
  22. hintNumberOfParams(myxuihandle, numParams);
  23. for (int i = 0;i < numParams;i++)
  24. addParam(myxuihandle, params[i], XUI_ATTRIBUTE_IMPLIED);
  25. }
  26. int XuiStatus::setXuiParam(int xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value) {
  27. if (xuihandle != myxuihandle)
  28. return XUISTATUS_PARENT::setXuiParam(xuihandle, xmlattributeid, xmlattributename, value);
  29. switch (xmlattributeid) {
  30. case EXCLUDE:
  31. setExclude(value);
  32. break;
  33. case INCLUDE:
  34. setIncludeOnly(value);
  35. break;
  36. default:
  37. return 0;
  38. }
  39. return 1;
  40. }
  41. // -----------------------------------------------------------------------
  42. void XuiStatus::callme(const wchar_t *str)
  43. {
  44. fakeButtonPush(str);
  45. }
  46. // -----------------------------------------------------------------------
  47. // Script Object
  48. // -- Functions table -------------------------------------
  49. function_descriptor_struct LayoutStatusController::exportedFunction[] = {
  50. {L"callme", 1, (void*)LayoutStatusController::layoutstatus_callme },
  51. };
  52. ScriptObject *LayoutStatusController::instantiate() {
  53. XuiStatus *xs = new XuiStatus;
  54. ASSERT(xs != NULL);
  55. return xs->getScriptObject();
  56. }
  57. void LayoutStatusController::destroy(ScriptObject *o) {
  58. XuiStatus *xs = static_cast<XuiStatus *>(o->vcpu_getInterface(layoutStatusGuid));
  59. ASSERT(xs!= NULL);
  60. delete xs;
  61. }
  62. void *LayoutStatusController::encapsulate(ScriptObject *o) {
  63. return NULL; // no encapsulation for layoutstatus yet
  64. }
  65. void LayoutStatusController::deencapsulate(void *o) {
  66. }
  67. int LayoutStatusController::getNumFunctions() {
  68. return sizeof(exportedFunction) / sizeof(function_descriptor_struct);
  69. }
  70. const function_descriptor_struct *LayoutStatusController::getExportedFunctions() {
  71. return exportedFunction;
  72. }
  73. scriptVar LayoutStatusController::layoutstatus_callme(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar str) {
  74. SCRIPT_FUNCTION_INIT
  75. XuiStatus *xs = static_cast<XuiStatus *>(o->vcpu_getInterface(layoutStatusGuid));
  76. if (xs) xs->callme(GET_SCRIPT_STRING(str));
  77. RETURN_SCRIPT_VOID;
  78. }