/***************************************************************************
 *   Copyright (C) 2009 by Juergen Thies                                   *
 *   layout@juergenthies.de                                                *
 *                                                                         *
 ***************************************************************************/
#include "textedit/textedit.h"

void macro::textEditHandler_registerKeywords(keywords **keyword_){
  *keyword_= new keywords(*keyword_);
 (*keyword_)->keyword="textEdit";
 (*keyword_)->type=type;
 (*keyword_)->typeHandler=&macro::textEditHandler_typeHandler;
}

void macro::textEditHandler_typeHandler(int *counter,keywords **keyword_,bool single){
generalTypeProcessing(counter,keyword_,ptrTextEdit,ptrTextEdit,single);
}

returnValue macro::textEditHandler_classHandler(int *counter, keywords *keyword_,returnValue* r,bool left){
 QString s;
 returnValue ret;
 parserValue p;
 if (r->type==ptrTextEdit){
   if (checkClassPointer(counter)) {
   }
   else { 
   	if (left) { compute(r,counter,keyword_);return ret;}
     	else return *r;
	}
   }
 textEdit *l= r->getTextEdit();
 p=next(counter);
 if ((p.type==keyword)&&(p.value=="filename")){
 		returnValue r2;
		r2.type=varString;
		r2.deleteAfter=false;
		r2.s=&(l->filename);
		//printf("fn %s\n",l->filename.toAscii().data());
		r2=stringHandler_classHandler(counter,keyword_,&r2,left);
		return r2;
 	}
else if ((p.type==keyword)&&(p.value=="drawing")){
 		returnValue r2;
		r2.setType(ptrTextDisplay);
		r2.deleteAfter=false;
		r2.TextDisplay=(l->drawing);
		r2=textDisplayHandler_classHandler(counter,keyword_,&r2,left);
		return r2;
 	}
/* else if ((p.type==keyword)&&(p.value=="firstSheet")){
 		returnValue r2;
		r2.setType(ptrSheetList);
		r2.deleteAfter=false;
		r2.SheetList=(l->firstSheet);
		r2=sheetListHandler_classHandler(counter,keyword_,&r2,left);
		return r2;}
 else if (((p.type==keyword)&&(p.value=="openFile"))) { testParenOpen(counter);
	returnValue s=calculate(counter,keyword_);testParenClose(counter);
	l->openFile(s.getString());}
 else if (((p.type==keyword)&&(p.value=="saveFile"))) { testParenOpen(counter);
	returnValue s=calculate(counter,keyword_);testParenClose(counter);
	l->saveFile(s.getString());}
 else if (((p.type==keyword)&&(p.value=="scaleFull"))) { testParenOpen(counter);testParenClose(counter);
	l->scaleFull();}
 else if (((p.type==keyword)&&(p.value=="saveNetList"))) { testParenOpen(counter);
	returnValue p1=calculate(counter,keyword_);testComma(counter);
	returnValue p2=calculate(counter,keyword_);testParenClose(counter);
   	l->saveNetList(p1.getString(),p2.getString());
	}
 else if (((p.type==keyword)&&(p.value=="generateNetList"))) { testParenOpen(counter);
	returnValue p1=calculate(counter,keyword_);
	if (checkParenClose(counter)){
	  ret.setString(l->generateNetList(p1.getString()));
	}
	else {
	  testComma(counter);
	  returnValue p2=calculate(counter,keyword_);testParenClose(counter);
	  ret.setString(l->generateNetList(p1.getString(),p2.getString()));
	}
	ret=stringHandler_classHandler(counter,keyword_,&ret,false);
	}*/
 else {
  	error->addItem(tr("Class textEdit has no member ")+p.value,1,message((*counter)));
	throw 1;
 	}
 if (left)  if (!checkSemicolon(counter)) {throw 15;}  
 return ret;
}

