#include <WScom.h>
#include <WSCfunctionList.h>
#include <WSCbase.h>
//----------------------------------------------------------
//Function for the event procedure
//----------------------------------------------------------
static void _in_ep(WSCbase* object);
static void _out_ep(WSCbase* object);

void hlight(WSCbase* object){
  //Set up the event procedure:_in_ep() with  MOUSE-IN trigger
  WSCprocedure* ep0 = new WSCprocedure("ハイライトON",WSEV_MOUSE_IN);
  ep0->setFunction(_in_ep,"_in_ep");
  object->addProcedure(ep0);

  //Set up the event procedure:_out_ep() with  MOUSE-OUT trigger
  WSCprocedure* ep1 = new WSCprocedure("ハイライトOFF",WSEV_MOUSE_OUT);
  ep1->setFunction(_out_ep,"_out_ep");
  object->addProcedure(ep1);

}

void _in_ep(WSCbase* object){
  //Get the original backcolor.
  WSCvariant col = object->getProperty(WSNbackColor);
  //Store the original backcolor to WSNuserString to memorize.
  object->setProperty(WSNuserString,col);
  //Store the highlight color to WSNbackColor.
  object->setProperty(WSNbackColor,"gray90");
}
void _out_ep(WSCbase* object){
  //Get the original backcolor from WSNuserString.
  WSCvariant col = object->getProperty(WSNuserString);
  //Store the original backcolor to WSNbackColor.
  object->setProperty(WSNbackColor,col);
}

static WSCfunctionRegister  op("hlight",(void*)hlight);
