#include <WScom.h>
#include <WSCfunctionList.h>
#include <WSCbase.h>

#include <WSCmessageDialog.h>
#include <WSCtextField.h>

//----------------------------------------------------------
//Function for the event procedure
//----------------------------------------------------------
extern WSCstring backup;
extern WSCtextField* newtext_001;
extern void m13ep(WSCbase*);
extern void m14ep(WSCbase*);

void m11ep(WSCbase* object){
  //do something...
  WSCstring text;
  text = newtext_001->getProperty(WSNlabelString);
  if (!strcmp((char*)text,(char*)backup)){
    //same...
  }else{
    WSCstring fname;
    fname = newtext_001->getProperty(WSNuserString);
    if (!strcmp((char*)fname,"")){
      m14ep(object); //rename save..
    }else{
      WSCmessageDialog* msg = WSGIappMessageDialog();
      WSCstring message;
      message << "file: " << (char*)fname
              << "\nUnsaved changes. Save it?";
      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..
      }
    }
  }
  backup = "";
  newtext_001->setProperty(WSNlabelString,"");
  newtext_001->setProperty(WSNuserString,"");
}
static WSCfunctionRegister  op("m11ep",(void*)m11ep);
