3 void DrScript::DrMessage(
const char * s, ...)
8 vfprintf(stderr, s, args);
18 DrScript::~DrScript(){
20 void DrScript::IncrSlide(){
24 void DrScript::paintEvent(QPaintEvent *){
25 DrMessage(
"DrScript.paintEvent");
27 p.setPen(QPen(Qt::black,1,Qt::DashLine,Qt::RoundCap,Qt::RoundJoin));
28 p.drawRect(0,0,width(),height());
29 p.setFont(QFont(
"Helvetica",12 ));
32 void DrScript::ReadSlide(QPainter *p){
33 DrMessage(
"DrScript.ReadSlide");
34 if((File2Read = fopen(
"DrScript.dr",
"r"))==0){
37 char *cLine = (
char *)calloc(256,
sizeof(
char));
38 for(
int k=0;!(fgets(cLine,256,File2Read)==NULL);k++){
39 if(strncmp(cLine,
"Slide",5)==0){
41 fgets(cLine,256,File2Read);
42 sscanf(cLine,
"%d\n",&NSlide);
43 if(NSlide != Slide)
continue;
50 void DrScript::ExecScript(QPainter *p){
51 DrMessage(
"DrScript.ExecScript");
52 char *cLine = (
char *)calloc(256,
sizeof(
char));
53 double *From = (
double *)calloc(2,
sizeof(
double));
54 int *iFrom = (
int *)calloc(2,
sizeof(
int));
55 double *To = (
double *)calloc(2,
sizeof(
double));
56 int *iTo = (
int *)calloc(2,
sizeof(
int));
57 double *Hue = (
double *)calloc(4,
sizeof(
double));
58 int *iHue = (
int *)calloc(4,
sizeof(
int));
59 for(
int k=0;!(fgets(cLine,256,File2Read)==NULL);k++){
60 if(strncmp(cLine,
"Slide",5)==0)
break;
61 else if(strncmp(cLine,
"Testo",5)==0){
63 fgets(cLine,256,File2Read);
64 sscanf(cLine,
"%lf %lf %lf %lf\n",Hue,Hue+1,Hue+2,Hue+3);
65 for(
int i=0;i<4;i++) iHue[i] = (
int)(255.*Hue[i]);
66 p->setBrush( QColor(iHue[0],iHue[1],iHue[2],iHue[3]) );
68 fgets(cLine,256,File2Read);
69 sscanf(cLine,
"%lf %lf\n",From,From+1);
70 iFrom[0] = (int)(width()*From[0]);
71 iFrom[1] = (int)(height()*(1.-From[1]));
73 char *String = (
char *)calloc(512,
sizeof(
char));
74 fgets(cLine,512,File2Read);
75 for(
int c=0;c<strlen(cLine);c++)
77 p->drawText(iFrom[0],iFrom[1],QString(String),-1,Qt::AlignTop);
90 else if(strncmp(cLine,
"Picture",4)==0){
92 fgets(cLine,256,File2Read);
93 sscanf(cLine,
"%lf %lf\n",From,From+1);
94 iFrom[0] = (int)(width()*From[0]);
95 iFrom[1] = (int)(height()*(1.-From[1]));
97 fgets(cLine,256,File2Read);
98 sscanf(cLine,
"%lf %lf\n",To,To+1);
99 iTo[0] = (int)(width()*To[0]);
100 iTo[1] = (int)(height()*(1.-To[1]));
102 char *String = (
char *)calloc(512,
sizeof(
char));
103 fgets(cLine,512,File2Read);
105 for(
int c=0;c<strlen(cLine)-1;c++) String[c] = cLine[c];
108 p->drawImage(QRect(iFrom[0],iFrom[1],iTo[0],iTo[1]),QImage(QString(String),0));
111 else if(strncmp(cLine,
"Background",10)==0){