c_text.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* This file was generated by Maki Compiler, do not edit manually */
  2. #include <precomp.h>
  3. #include "c_text.h"
  4. #include <api/script/objcontroller.h>
  5. C_Text::C_Text(ScriptObject *object) : C_GuiObject(object) {
  6. inited = 0;
  7. obj = NULL;
  8. C_hook(object);
  9. }
  10. C_Text::C_Text() {
  11. inited = 0;
  12. obj = NULL;
  13. }
  14. void C_Text::C_hook(ScriptObject *object) {
  15. ASSERT(!inited);
  16. ScriptObjectController *controller = object->vcpu_getController();
  17. obj = controller->cast(object, textGuid);
  18. if (obj != object && obj != NULL)
  19. controller = obj->vcpu_getController();
  20. else
  21. obj = NULL;
  22. int iter = WASABI_API_APP->app_getInitCount();
  23. if (!loaded || loaded != iter) {
  24. loaded = iter;
  25. settext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setText", this);
  26. setalternatetext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setAlternateText", this);
  27. gettext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getText", this);
  28. gettextwidth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getTextWidth", this);
  29. ontextchanged_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onTextChanged", this);
  30. }
  31. inited = 1;
  32. }
  33. C_Text::~C_Text() {
  34. }
  35. ScriptObject *C_Text::getScriptObject() {
  36. if (obj != NULL) return obj;
  37. return C_TEXT_PARENT::getScriptObject();
  38. }
  39. void C_Text::setText(const wchar_t *txt)
  40. {
  41. ASSERT(inited);
  42. scriptVar a = MAKE_SCRIPT_STRING(txt);
  43. scriptVar *params[1] = {&a};
  44. WASABI_API_MAKI->maki_callFunction(getScriptObject(), settext_id, params);
  45. }
  46. void C_Text::setAlternateText(const wchar_t *txt)
  47. {
  48. ASSERT(inited);
  49. scriptVar a = MAKE_SCRIPT_STRING(txt);
  50. scriptVar *params[1] = {&a};
  51. WASABI_API_MAKI->maki_callFunction(getScriptObject(), setalternatetext_id, params);
  52. }
  53. const wchar_t *C_Text::getText()
  54. {
  55. ASSERT(inited);
  56. return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettext_id, NULL));
  57. }
  58. int C_Text::getTextWidth()
  59. {
  60. ASSERT(inited);
  61. return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettextwidth_id, NULL));
  62. }
  63. void C_Text::onTextChanged(const wchar_t *newtxt)
  64. {
  65. ASSERT(inited);
  66. scriptVar a = MAKE_SCRIPT_STRING(newtxt);
  67. scriptVar *params[1] = {&a};
  68. WASABI_API_MAKI->maki_callFunction(getScriptObject(), ontextchanged_id, params);
  69. }
  70. int C_Text::loaded=0;
  71. int C_Text::settext_id=0;
  72. int C_Text::setalternatetext_id=0;
  73. int C_Text::gettext_id=0;
  74. int C_Text::gettextwidth_id=0;
  75. int C_Text::ontextchanged_id=0;