[Cpri-develop] cpri/src drv_stdwin.c,1.14,1.15
Brought to you by:
chrisan,
rasmusmyklebust
|
From: <ras...@us...> - 2003-04-09 12:32:26
|
Update of /cvsroot/cpri/cpri/src
In directory sc8-pr-cvs1:/tmp/cvs-serv7052/src
Modified Files:
drv_stdwin.c
Log Message:
Fixed bug with pagebreakings.
Added x and y scaling to avoid problem on printers with different resolution i x an y.
Index: drv_stdwin.c
===================================================================
RCS file: /cvsroot/cpri/cpri/src/drv_stdwin.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** drv_stdwin.c 6 Apr 2003 23:14:07 -0000 1.14
--- drv_stdwin.c 9 Apr 2003 12:32:22 -0000 1.15
***************
*** 99,103 ****
int topmargin;
int bottom; /* "soft" bottom margin */
! float scaling; /* Scaling factor (currently values will be scaled from mm to suitabble values for the printer) */
int rowheight; /* The heigth of each line used for demand line feed */
int heightpercent; /* The row-heigth expressed in % of standard height 4.2mm/12dpi font */
--- 99,104 ----
int topmargin;
int bottom; /* "soft" bottom margin */
! int minbottom;
! float xscaling,yscaling; /* Scaling factor (currently values will be scaled from mm to suitabble values for the printer) */
int rowheight; /* The heigth of each line used for demand line feed */
int heightpercent; /* The row-heigth expressed in % of standard height 4.2mm/12dpi font */
***************
*** 382,393 ****
static void GetRes(t_driver *dd)
{
! dd->pagelen=GetDeviceCaps(dd->ghdc,HORZRES);
! dd->scaling=(float)dd->pagelen/GetDeviceCaps(dd->ghdc,HORZSIZE);
dd->pagelen=GetDeviceCaps(dd->ghdc,PHYSICALHEIGHT);
- // dd->scaling=GetDeviceCaps(dd->ghdc,SCALINGFACTORY);
dd->xoffset=GetDeviceCaps(dd->ghdc,PHYSICALOFFSETX);
dd->yoffset=GetDeviceCaps(dd->ghdc,PHYSICALOFFSETY);
dd->pagewidth=GetDeviceCaps(dd->ghdc,HORZRES);
!
}
--- 383,393 ----
static void GetRes(t_driver *dd)
{
! dd->xscaling=(float)GetDeviceCaps(dd->ghdc,HORZRES)/GetDeviceCaps(dd->ghdc,HORZSIZE);
! dd->yscaling=(float)GetDeviceCaps(dd->ghdc,VERTRES)/GetDeviceCaps(dd->ghdc,VERTSIZE);
dd->pagelen=GetDeviceCaps(dd->ghdc,PHYSICALHEIGHT);
dd->xoffset=GetDeviceCaps(dd->ghdc,PHYSICALOFFSETX);
dd->yoffset=GetDeviceCaps(dd->ghdc,PHYSICALOFFSETY);
dd->pagewidth=GetDeviceCaps(dd->ghdc,HORZRES);
! dd->minbottom=dd->pagelen-(GetDeviceCaps(dd->ghdc,VERTRES)+dd->yoffset);
}
***************
*** 639,643 ****
MoveToEx(dd->ghdc,dd->xpos,dd->ypos,NULL);
if(bar)
! LineTo(dd->ghdc,dd->xpos,dd->ypos-(long)(dd->barh*dd->scaling+0.5));
dd->xpos++;
}
--- 639,643 ----
MoveToEx(dd->ghdc,dd->xpos,dd->ypos,NULL);
if(bar)
! LineTo(dd->ghdc,dd->xpos,dd->ypos-(long)(dd->barh*dd->yscaling+0.5));
dd->xpos++;
}
***************
*** 693,698 ****
/* The startsequence of bars: */
- // p += sprintf(p, "%s%s%s%s", drv_fmt[EPC_NBAR], dd->nspace,
- // drv_fmt[EPC_NBAR], dd->nspace);
PrintOneBar(dd,0,1);
PrintOneBar(dd,0,0);
--- 693,696 ----
***************
*** 709,719 ****
}
/* the stopsequence of bars: */
-
-
- // p += sprintf(p, "%s%s%s", dd->wbar, dd->nspace, drv_fmt[EPC_NBAR]);
PrintOneBar(dd,1,1);
PrintOneBar(dd,0,0);
PrintOneBar(dd,0,1);
-
}
--- 707,713 ----
***************
*** 732,736 ****
dd->ActiveFormat.ActiveFont.size = 12;
dd->ActiveFormat.ActiveFont.face = COURIER;
- dd->scaling = (int)(SCALING / 25.4);
pd.lStructSize=sizeof(PRINTDLG);
--- 726,729 ----
***************
*** 841,845 ****
switch (c) {
case EPC_ABS_MOVEY:
! param = (int)((uscp=GetParam(q)) * dd->scaling + 0.5);
dd->ypos = param-dd->yoffset;
--- 834,838 ----
switch (c) {
case EPC_ABS_MOVEY:
! param = (int)((uscp=GetParam(q)) * dd->yscaling + 0.5);
dd->ypos = param-dd->yoffset;
***************
*** 848,862 ****
break;
case EPC_REL_MOVEX:
! param = (int)((uscp=GetParam(q)) * dd->scaling + 0.5);
dd->xpos+=param;
dprintf("R_RELMOVEX %d\n",uscp);
break;
case EPC_REL_MOVEY:
! param = (int)((uscp=GetParam(q)) * dd->scaling + 0.5);
dd->ypos += param;
dprintf("R_RELMOVEY %d\n",uscp);
break;
case EPC_ABS_MOVEX:
! param = (int)((uscp=GetParam(q)) * dd->scaling + 0.5);
dd->xpos=param-dd->xoffset;
dprintf("ABSMOVEX to %d\n",dd->xpos);
--- 841,855 ----
break;
case EPC_REL_MOVEX:
! param = (int)((uscp=GetParam(q)) * dd->xscaling + 0.5);
dd->xpos+=param;
dprintf("R_RELMOVEX %d\n",uscp);
break;
case EPC_REL_MOVEY:
! param = (int)((uscp=GetParam(q)) * dd->yscaling + 0.5);
dd->ypos += param;
dprintf("R_RELMOVEY %d\n",uscp);
break;
case EPC_ABS_MOVEX:
! param = (int)((uscp=GetParam(q)) * dd->xscaling + 0.5);
dd->xpos=param-dd->xoffset;
dprintf("ABSMOVEX to %d\n",dd->xpos);
***************
*** 864,870 ****
break;
case EPC_RECTANGLE:
! fwidth = GetFloatParam(q) * dd->scaling;
! fheight = GetFloatParam(q) * dd->scaling;
! dprintf("R_RECT %f %f\n",fwidth/dd->scaling,fheight/dd->scaling);
DrawRect(dd->ghdc,dd->xpos,dd->ypos,dd->xpos+fwidth,dd->ypos+fheight);
--- 857,863 ----
break;
case EPC_RECTANGLE:
! fwidth = GetFloatParam(q) * dd->xscaling;
! fheight = GetFloatParam(q) * dd->yscaling;
! dprintf("R_RECT %f %f\n",fwidth/dd->xscaling,fheight/dd->yscaling);
DrawRect(dd->ghdc,dd->xpos,dd->ypos,dd->xpos+fwidth,dd->ypos+fheight);
***************
*** 905,920 ****
//x
param=GetParam(q);
! _CpriInitTabs(&dd->ActiveFormat.tf,0,dd->scaling);
! if(param*dd->scaling<dd->xoffset)
! param=dd->xoffset/dd->scaling+1;
! _CpriSetSoftMargin(&dd->ActiveFormat.tf, &dd->ActiveFormat.margin, param, dd->scaling);
//y
! dd->topmargin = (int)((GetParam(q)) * dd->scaling + 0.5)-dd->yoffset;
if(dd->ypos<dd->topmargin)
dd->ypos=dd->topmargin;
dd->linebreaking=1;
//bottom
! dd->bottom = (int)(GetParam(q) * dd->scaling + 0.5);
!
break;
case EPC_END_TABLE:
--- 898,915 ----
//x
param=GetParam(q);
! _CpriInitTabs(&dd->ActiveFormat.tf,0,dd->xscaling);
! if(param*dd->xscaling<dd->xoffset)
! param=dd->xoffset/dd->xscaling+1;
! _CpriSetSoftMargin(&dd->ActiveFormat.tf, &dd->ActiveFormat.margin, param, dd->xscaling);
//y
! dd->topmargin = (int)((GetParam(q)) * dd->yscaling + 0.5)-dd->yoffset;
if(dd->ypos<dd->topmargin)
dd->ypos=dd->topmargin;
dd->linebreaking=1;
//bottom
! dd->bottom = (int)(GetParam(q) * dd->yscaling + 0.5);
! if(dd->bottom<dd->minbottom)
! dd->bottom=dd->minbottom;
! dd->bottom+=dd->yoffset;
break;
case EPC_END_TABLE:
***************
*** 938,942 ****
break;
case EPC_CREATE_COLUMN: /* settab */
! _CpriSetTab(&dd->ActiveFormat.tf, GetParam(q), dd->scaling);
break;
--- 933,937 ----
break;
case EPC_CREATE_COLUMN: /* settab */
! _CpriSetTab(&dd->ActiveFormat.tf, GetParam(q), dd->xscaling);
break;
***************
*** 957,961 ****
if (dd->ActiveFormat.tf.curtab >= dd->ActiveFormat.tf.n)
break;
! dd->xpos=dd->ActiveFormat.tf.tabs[dd->ActiveFormat.tf.curtab].scaled-dd->xoffset+(int)(dd->scaling+0.5);
dprintf("Jumping to tab %d at pos %d = %d mm\n",dd->ActiveFormat.tf.curtab,dd->ActiveFormat.tf.tabs[dd->ActiveFormat.tf.curtab].scaled,dd->ActiveFormat.tf.tabs[dd->ActiveFormat.tf.curtab].mm);
_CpriMoveToNextCell(&dd->ActiveFormat.tf);
--- 952,956 ----
if (dd->ActiveFormat.tf.curtab >= dd->ActiveFormat.tf.n)
break;
! dd->xpos=dd->ActiveFormat.tf.tabs[dd->ActiveFormat.tf.curtab].scaled-dd->xoffset+(int)(dd->xscaling+0.5);
dprintf("Jumping to tab %d at pos %d = %d mm\n",dd->ActiveFormat.tf.curtab,dd->ActiveFormat.tf.tabs[dd->ActiveFormat.tf.curtab].scaled,dd->ActiveFormat.tf.tabs[dd->ActiveFormat.tf.curtab].mm);
_CpriMoveToNextCell(&dd->ActiveFormat.tf);
***************
*** 1018,1022 ****
}
width=size.cx;
! xpos=dd->ActiveFormat.tf.tabs[dd->ActiveFormat.tf.curtab].scaled-dd->xoffset-width-(int)(dd->scaling+0.5);
dd->xpos=xpos;
if(dd->NextToken[-1]=='½')
--- 1013,1017 ----
}
width=size.cx;
! xpos=dd->ActiveFormat.tf.tabs[dd->ActiveFormat.tf.curtab].scaled-dd->xoffset-width-(int)(dd->xscaling+0.5);
dd->xpos=xpos;
if(dd->NextToken[-1]=='½')
***************
*** 1040,1044 ****
err=GetLastError();
}
! xpos=dd->ActiveFormat.tf.tabs[dd->ActiveFormat.tf.curtab].scaled-dd->xoffset-width-(int)(dd->scaling+0.5);
if(!GetCharWidth32(dd->ghdc,'.','.',&width))
{
--- 1035,1039 ----
err=GetLastError();
}
! xpos=dd->ActiveFormat.tf.tabs[dd->ActiveFormat.tf.curtab].scaled-dd->xoffset-width-(int)(dd->xscaling+0.5);
if(!GetCharWidth32(dd->ghdc,'.','.',&width))
{
***************
*** 1061,1065 ****
case ALIGN_RIGHT:
SetTextAlign(dd->ghdc,VERT_TEXT_ALIGN|TA_RIGHT|TA_UPDATECP);
! dd->xpos=dd->ActiveFormat.tf.tabs[dd->ActiveFormat.tf.curtab].scaled-dd->xoffset-(int)(dd->scaling+0.5);
break;
}
--- 1056,1060 ----
case ALIGN_RIGHT:
SetTextAlign(dd->ghdc,VERT_TEXT_ALIGN|TA_RIGHT|TA_UPDATECP);
! dd->xpos=dd->ActiveFormat.tf.tabs[dd->ActiveFormat.tf.curtab].scaled-dd->xoffset-(int)(dd->xscaling+0.5);
break;
}
***************
*** 1068,1072 ****
break;
case EPC_SUP_RALIGN_CELL:
! dd->xpos=dd->ActiveFormat.tf.tabs[dd->ActiveFormat.tf.curtab].scaled-dd->xoffset-(int)(dd->scaling+0.5);
SetTextAlign(dd->ghdc,VERT_TEXT_ALIGN|TA_RIGHT|TA_UPDATECP);
case EPC_SUP:
--- 1063,1067 ----
break;
case EPC_SUP_RALIGN_CELL:
! dd->xpos=dd->ActiveFormat.tf.tabs[dd->ActiveFormat.tf.curtab].scaled-dd->xoffset-(int)(dd->xscaling+0.5);
SetTextAlign(dd->ghdc,VERT_TEXT_ALIGN|TA_RIGHT|TA_UPDATECP);
case EPC_SUP:
***************
*** 1109,1113 ****
break;
case EPC_BAR_CODE_W:
! dd->barw = (int)(GetParam(q)/100.0*dd->scaling+0.5);
break;
case EPC_BAR_CODE_H:
--- 1104,1108 ----
break;
case EPC_BAR_CODE_W:
! dd->barw = (int)(GetParam(q)/100.0*dd->xscaling+0.5);
break;
case EPC_BAR_CODE_H:
***************
*** 1120,1125 ****
for(i=0;i<5;i++)
{
! p[i].x=p[i].x*dd->scaling/2/12*dd->ActiveFormat.ActiveFont.size+dd->xpos+0.5;
! p[i].y=p[i].y*dd->scaling/2/12*dd->ActiveFormat.ActiveFont.size+dd->ypos+0.5;
}
--- 1115,1120 ----
for(i=0;i<5;i++)
{
! p[i].x=p[i].x*dd->xscaling/2/12*dd->ActiveFormat.ActiveFont.size+dd->xpos+0.5;
! p[i].y=p[i].y*dd->yscaling/2/12*dd->ActiveFormat.ActiveFont.size+dd->ypos+0.5;
}
***************
*** 1163,1167 ****
GetRes(dd);
if(dd->barw==0)
! dd->barw=(int)(NBARWIDTH*dd->scaling+0.5);
break;
case EPC_CASSETTE_FEED:
--- 1158,1162 ----
GetRes(dd);
if(dd->barw==0)
! dd->barw=(int)(NBARWIDTH*dd->xscaling+0.5);
break;
case EPC_CASSETTE_FEED:
|