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

void macro::schematicDisplayHandler_registerKeywords(keywords **keyword_){
  *keyword_= new keywords(*keyword_);
 (*keyword_)->keyword="schematicDisplay";
 (*keyword_)->type=type;
 (*keyword_)->typeHandler=&macro::schematicDisplayHandler_typeHandler;
}

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

returnValue macro::schematicDisplayHandler_classHandler(int *counter, keywords *keyword_,returnValue* r,bool left){
 QString s;
 returnValue ret;
 parserValue p;
 if (r->type==ptrSchematicDisplay){
   if (checkClassPointer(counter)) {
   }
   else { 
   	if (left) { compute(r,counter,keyword_);return ret;}
     	else return *r;
	}
   }
 schematicDisplay *l= r->getSchematicDisplay();
 p=next(counter);
 if ((p.type==keyword)&&(p.value=="currentSheet")){
 		returnValue r2;
		r2.setType(ptrSheet);
		r2.deleteAfter=false;
		r2.Sheet=(l->currentSheet);
		r2=sheetHandler_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=="scrollLeft"))) { testParenOpen(counter);testParenClose(counter);
	l->scrollLeft();}
 else if (((p.type==keyword)&&(p.value=="scrollRight"))) { testParenOpen(counter);testParenClose(counter);
	l->scrollRight();}
 else if (((p.type==keyword)&&(p.value=="scrollUp"))) { testParenOpen(counter);testParenClose(counter);
	l->scrollUp();}
 else if (((p.type==keyword)&&(p.value=="scrollDown"))) { testParenOpen(counter);testParenClose(counter);
	l->scrollDown();}
 else if (((p.type==keyword)&&(p.value=="scalePlus"))) { testParenOpen(counter);testParenClose(counter);
	l->scalePlus();}
 else if (((p.type==keyword)&&(p.value=="scaleMinus"))) { testParenOpen(counter);testParenClose(counter);
	l->scaleMinus();}
 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 schematicDisplay has no member ")+p.value,1,message((*counter)));
	throw 1;
 	}
 if (left)  if (!checkSemicolon(counter)) {throw 15;}  
 return ret;
}

