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

#include <precomp.h>

#include <api/script/objcontroller.h>
#include "h_guitree.h"

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

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

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

  addMonitorObject(o, &guiTreeGuid);

  int iter = WASABI_API_APP->app_getInitCount();
  if (!loaded || loaded != iter) {
    onwantautocontextmenu_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onWantAutoContextMenu", this);
    onmousewheelup_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMouseWheelUp", this);
    onmousewheeldown_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMouseWheelDown", this);
    oncontextmenu_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onContextMenu", this);
    onchar_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onChar", this);
    onitemrecvdrop_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onItemRecvDrop", this);
    onlabelchange_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLabelChange", this);
    onitemselected_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onItemSelected", this);
    onitemdeselected_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onItemDeselected", this);
    loaded = 1;
  }
  inited=1;
}

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

ScriptObject *H_GuiTree::getHookedObject() {
  if (obj != NULL) return obj;
  return H_GUITREE_PARENT::getHookedObject();
}

int H_GuiTree::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) {
  if (object != getHookedObject()) return 0;
  if (H_GUITREE_PARENT::eventCallback(object, dlfid, params, nparams)) return 1;
  if (dlfid == onwantautocontextmenu_id) { hook_onWantAutoContextMenu(); return 1; }
  if (dlfid == onmousewheelup_id) { hook_onMouseWheelUp(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; }
  if (dlfid == onmousewheeldown_id) { hook_onMouseWheelDown(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; }
  if (dlfid == oncontextmenu_id) { hook_onContextMenu(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; }
  if (dlfid == onchar_id) { hook_onChar(GET_SCRIPT_INT(*params[0])); return 1; }
  if (dlfid == onitemrecvdrop_id) { hook_onItemRecvDrop(GET_SCRIPT_OBJECT(*params[0])); return 1; }
  if (dlfid == onlabelchange_id) { hook_onLabelChange(GET_SCRIPT_OBJECT(*params[0])); return 1; }
  if (dlfid == onitemselected_id) { hook_onItemSelected(GET_SCRIPT_OBJECT(*params[0])); return 1; }
  if (dlfid == onitemdeselected_id) { hook_onItemDeselected(GET_SCRIPT_OBJECT(*params[0])); return 1; }
  return 0;
}

int H_GuiTree::onwantautocontextmenu_id=0;
int H_GuiTree::onmousewheelup_id=0;
int H_GuiTree::onmousewheeldown_id=0;
int H_GuiTree::oncontextmenu_id=0;
int H_GuiTree::onchar_id=0;
int H_GuiTree::onitemrecvdrop_id=0;
int H_GuiTree::onlabelchange_id=0;
int H_GuiTree::onitemselected_id=0;
int H_GuiTree::onitemdeselected_id=0;
int H_GuiTree::loaded=0;