#include <WScom.h>
#include <WSCfunctionList.h>
#include <WSCbase.h>
//----------------------------------------------------------
//Function for the event procedure
//----------------------------------------------------------
#include <WSCmessageDialog.h>
#include <WSCtextField.h>
extern WSCtextField* newtext_001;

extern WSCstring backup;
extern void m14ep(WSCbase*);
extern void m13ep(WSCbase*);

void exitep(WSCbase* object){
  if (object->getVisible() == False){
    WSCstring text;
    text = newtext_001->getProperty(WSNlabelString);
    if (!strcmp((char*)text,(char*)backup)){
      exit(0);
    }else{
      WSCstring fname;
      fname = newtext_001->getProperty(WSNuserString);
      if (!strcmp((char*)fname,"")){
        WSCmessageDialog* msg = WSGIappMessageDialog();
        WSCstring message;
        message << "파일은 편집되여있습니다. \n"
                << "저장하겠습니까?";
        msg->setProperty(WSNdefaultPosition,True);
        msg->setProperty(WSNwidth,400);
        msg->setProperty(WSNheight,130);
        msg->setProperty(WSNlabelString,message);
        long ret = msg->popup();
        if (ret == WS_DIALOG_OK){
          m14ep(object); //rename save..
        }
      }else{
        WSCmessageDialog* msg = WSGIappMessageDialog();
        WSCstring message;
        message << "file: " << (char*)fname
                << " 는/은 편집되여있습니다. \n"
                << "저장하겠습니까?";
        msg->setProperty(WSNdefaultPosition,True);
        msg->setProperty(WSNwidth,400);
        msg->setProperty(WSNheight,130);
        msg->setProperty(WSNlabelString,message);
        long ret = msg->popup();
        if (ret == WS_DIALOG_OK){
          m13ep(object); //rename save..
        }else if (ret == WS_DIALOG_CANCEL){
          return;
        }
      }
      exit(0);
    }
  }
}
static WSCfunctionRegister  op("exitep",(void*)exitep);
