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

#include <precomp.h>

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

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

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

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

  addMonitorObject(o, &treeItemGuid);

  int iter = WASABI_API_APP->app_getInitCount();
  if (!loaded || loaded != iter) {
    ontreeadd_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onTreeAdd", this);
    ontreeremove_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onTreeRemove", this);
    onselect_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSelect", this);
    ondeselect_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onDeselect", this);
    onleftdoubleclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftDoubleClick", this);
    onrightdoubleclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightDoubleClick", this);
    onchar_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onChar", this);
    onexpand_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onExpand", this);
    oncollapse_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onCollapse", this);
    onbeginlabeledit_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onBeginLabelEdit", this);
    onendlabeledit_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onEndLabelEdit", this);
    oncontextmenu_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onContextMenu", this);
    loaded = 1;
  }
  inited=1;
}

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

ScriptObject *H_TreeItem::getHookedObject() {
  if (obj != NULL) return obj;
  return H_TREEITEM_PARENT::getHookedObject();
}

int H_TreeItem::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) {
  if (object != getHookedObject()) return 0;
  if (H_TREEITEM_PARENT::eventCallback(object, dlfid, params, nparams)) return 1;
  if (dlfid == ontreeadd_id) { hook_onTreeAdd(); return 1; }
  if (dlfid == ontreeremove_id) { hook_onTreeRemove(); return 1; }
  if (dlfid == onselect_id) { hook_onSelect(); return 1; }
  if (dlfid == ondeselect_id) { hook_onDeselect(); return 1; }
  if (dlfid == onleftdoubleclick_id) { hook_onLeftDoubleClick(); return 1; }
  if (dlfid == onrightdoubleclick_id) { hook_onRightDoubleClick(); return 1; }
  if (dlfid == onchar_id) { hook_onChar(GET_SCRIPT_INT(*params[0])); return 1; }
  if (dlfid == onexpand_id) { hook_onExpand(); return 1; }
  if (dlfid == oncollapse_id) { hook_onCollapse(); return 1; }
  if (dlfid == onbeginlabeledit_id) { hook_onBeginLabelEdit(); return 1; }
  if (dlfid == onendlabeledit_id) { hook_onEndLabelEdit(GET_SCRIPT_STRING(*params[0])); return 1; }
  if (dlfid == oncontextmenu_id) { hook_onContextMenu(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; }
  return 0;
}

int H_TreeItem::ontreeadd_id=0;
int H_TreeItem::ontreeremove_id=0;
int H_TreeItem::onselect_id=0;
int H_TreeItem::ondeselect_id=0;
int H_TreeItem::onleftdoubleclick_id=0;
int H_TreeItem::onrightdoubleclick_id=0;
int H_TreeItem::onchar_id=0;
int H_TreeItem::onexpand_id=0;
int H_TreeItem::oncollapse_id=0;
int H_TreeItem::onbeginlabeledit_id=0;
int H_TreeItem::onendlabeledit_id=0;
int H_TreeItem::oncontextmenu_id=0;
int H_TreeItem::loaded=0;
