/* This file was generated by Maki Compiler, do not edit manually */

#include <precomp.h>

#include <api/script/objcontroller.h>
#include "h_guiobject.h"
#include "../nu/AUtoChar.h"

H_GuiObject::H_GuiObject(ScriptObject *o) : H_RootObject(o) {
  inited = 0;
  obj = NULL;
  H_hook(o);
}

H_GuiObject::H_GuiObject() {
  inited = 0;
  obj = NULL;
}

void H_GuiObject::H_hook(ScriptObject *o) {
  ASSERT(!inited);
  ScriptObjectController *controller = o->vcpu_getController();
  obj = controller->cast(o, guiObjectGuid);
  if (obj != o && obj != NULL)
    o = obj;
  else
    obj = NULL;

  addMonitorObject(o, &guiObjectGuid);

  int iter = WASABI_API_APP->app_getInitCount();
  if (!loaded || loaded != iter) {
    onsetvisible_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSetVisible", this);
    onleftbuttonup_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftButtonUp", this);
    onleftbuttondown_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftButtonDown", this);
    onrightbuttonup_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightButtonUp", this);
    onrightbuttondown_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightButtonDown", this);
    onrightbuttondblclk_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightButtonDblClk", this);
    onleftbuttondblclk_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftButtonDblClk", this);
    onmousemove_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMouseMove", this);
    onenterarea_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onEnterArea", this);
    onleavearea_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeaveArea", this);
    onenable_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onEnable", this);
    onresize_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onResize", this);
    ontargetreached_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onTargetReached", this);
    onstartup_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onStartup", this);
    onchar_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onChar", this);
    onaccelerator_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onAccelerator", this);
    onkeydown_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onKeyDown", this);
    onkeyup_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onKeyUp", this);
    ongetfocus_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onGetFocus", this);
    onkillfocus_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onKillFocus", this);
    onaction_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onAction", this);
    loaded = 1;
  }
  inited=1;
}

H_GuiObject::~H_GuiObject() {
  if (!inited) return;
  WASABI_API_MAKI->maki_remDlfRef(this);
}

ScriptObject *H_GuiObject::getHookedObject() {
  if (obj != NULL) return obj;
  return H_GUIOBJECT_PARENT::getHookedObject();
}

int H_GuiObject::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) {
  if (object != getHookedObject()) return 0;
  if (H_GUIOBJECT_PARENT::eventCallback(object, dlfid, params, nparams)) return 1;
  if (dlfid == onsetvisible_id) { hook_onSetVisible(GET_SCRIPT_INT(*params[0])); return 1; }
  if (dlfid == onleftbuttonup_id) { hook_onLeftButtonUp(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; }
  if (dlfid == onleftbuttondown_id) { hook_onLeftButtonDown(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; }
  if (dlfid == onrightbuttonup_id) { hook_onRightButtonUp(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; }
  if (dlfid == onrightbuttondown_id) { hook_onRightButtonDown(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; }
  if (dlfid == onrightbuttondblclk_id) { hook_onRightButtonDblClk(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; }
  if (dlfid == onleftbuttondblclk_id) { hook_onLeftButtonDblClk(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; }
  if (dlfid == onmousemove_id) { hook_onMouseMove(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; }
  if (dlfid == onenterarea_id) { hook_onEnterArea(); return 1; }
  if (dlfid == onleavearea_id) { hook_onLeaveArea(); return 1; }
  if (dlfid == onenable_id) { hook_onEnable(GET_SCRIPT_INT(*params[0])); return 1; }
  if (dlfid == onresize_id) { hook_onResize(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1]), GET_SCRIPT_INT(*params[2]), GET_SCRIPT_INT(*params[3])); return 1; }
  if (dlfid == ontargetreached_id) { hook_onTargetReached(); return 1; }
  if (dlfid == onstartup_id) { hook_onStartup(); return 1; }
  if (dlfid == onchar_id) { hook_onChar(GET_SCRIPT_STRING(*params[0])); return 1; }
  if (dlfid == onaccelerator_id) { hook_onAccelerator(GET_SCRIPT_STRING(*params[0])); return 1; }
  if (dlfid == onkeydown_id) { hook_onKeyDown(GET_SCRIPT_INT(*params[0])); return 1; }
  if (dlfid == onkeyup_id) { hook_onKeyUp(GET_SCRIPT_INT(*params[0])); return 1; }
  if (dlfid == ongetfocus_id) { hook_onGetFocus(); return 1; }
  if (dlfid == onkillfocus_id) { hook_onKillFocus(); return 1; }
  if (dlfid == onaction_id) { hook_onAction(GET_SCRIPT_STRING(*params[0]), GET_SCRIPT_STRING(*params[1]), GET_SCRIPT_INT(*params[2]), GET_SCRIPT_INT(*params[3]), GET_SCRIPT_INT(*params[4]), GET_SCRIPT_INT(*params[5]), GET_SCRIPT_OBJECT(*params[6])); return 1; }
  return 0;
}

int H_GuiObject::onsetvisible_id=0;
int H_GuiObject::onleftbuttonup_id=0;
int H_GuiObject::onleftbuttondown_id=0;
int H_GuiObject::onrightbuttonup_id=0;
int H_GuiObject::onrightbuttondown_id=0;
int H_GuiObject::onrightbuttondblclk_id=0;
int H_GuiObject::onleftbuttondblclk_id=0;
int H_GuiObject::onmousemove_id=0;
int H_GuiObject::onenterarea_id=0;
int H_GuiObject::onleavearea_id=0;
int H_GuiObject::onenable_id=0;
int H_GuiObject::onresize_id=0;
int H_GuiObject::ontargetreached_id=0;
int H_GuiObject::onstartup_id=0;
int H_GuiObject::onchar_id=0;
int H_GuiObject::onaccelerator_id=0;
int H_GuiObject::onkeydown_id=0;
int H_GuiObject::onkeyup_id=0;
int H_GuiObject::ongetfocus_id=0;
int H_GuiObject::onkillfocus_id=0;
int H_GuiObject::onaction_id=0;
int H_GuiObject::loaded=0;