1995-03-22 09:07:04 +00:00
|
|
|
|
#include <applicat.h>
|
2002-02-28 11:35:23 +00:00
|
|
|
|
#include <image.h>
|
1995-04-20 14:35:14 +00:00
|
|
|
|
#include <printer.h>
|
1994-09-13 16:43:52 +00:00
|
|
|
|
#include <printwin.h>
|
1994-11-03 09:03:14 +00:00
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
|
HIDDEN int LEN_SPACES(WINDOW win, int x)
|
|
|
|
|
{
|
2003-05-15 08:09:47 +00:00
|
|
|
|
HIDDEN int w = 0L;
|
|
|
|
|
|
|
|
|
|
const int columns = 132;
|
1995-05-10 15:40:06 +00:00
|
|
|
|
if (x < 0)
|
|
|
|
|
{
|
2003-05-15 08:09:47 +00:00
|
|
|
|
x = columns;
|
1995-05-10 15:40:06 +00:00
|
|
|
|
w = 0L;
|
2003-05-15 08:09:47 +00:00
|
|
|
|
}
|
1995-03-22 09:07:04 +00:00
|
|
|
|
if (w == 0L)
|
|
|
|
|
{
|
2003-05-15 08:09:47 +00:00
|
|
|
|
TString256 spc; spc.fill('m', columns);
|
|
|
|
|
w = xvt_dwin_get_text_width(win, spc.get_buffer(), columns);
|
1995-03-22 09:07:04 +00:00
|
|
|
|
}
|
2003-05-15 08:09:47 +00:00
|
|
|
|
const int tab = w * x / columns;
|
|
|
|
|
return tab;
|
1995-03-22 09:07:04 +00:00
|
|
|
|
}
|
1994-09-13 16:43:52 +00:00
|
|
|
|
|
|
|
|
|
void TPrintwin::paint_background(long j)
|
|
|
|
|
{
|
1995-04-20 14:35:14 +00:00
|
|
|
|
const bool isbackground = _bg->items() > 0 && printer().isgraphics();
|
1997-05-28 12:49:40 +00:00
|
|
|
|
const bool fink_mode = printer().get_fink_mode();
|
1994-09-13 16:43:52 +00:00
|
|
|
|
int rw = (int)(j % _formlen);
|
|
|
|
|
int cnt = 0; char ch;
|
|
|
|
|
|
|
|
|
|
char curcol = 'n';
|
|
|
|
|
char curpen = 'n';
|
|
|
|
|
char curpat = 'n';
|
|
|
|
|
char curwid = '1';
|
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
|
unsigned int x1, y1, x2, y2, id;
|
|
|
|
|
PNT b, e;
|
1995-12-22 12:01:15 +00:00
|
|
|
|
|
1997-05-28 12:49:40 +00:00
|
|
|
|
if (!fink_mode)
|
1995-12-22 12:01:15 +00:00
|
|
|
|
{
|
|
|
|
|
const char* line = printer().background_chars(rw);
|
|
|
|
|
set_color (COLOR_BLACK, COLOR_WHITE);
|
1996-01-03 16:03:08 +00:00
|
|
|
|
xvt_dwin_draw_text(win(), _hofs , (rw*_chary + _chary - _descent + _vofs), (char*)line, -1);
|
1997-05-28 12:49:40 +00:00
|
|
|
|
// return;
|
1995-12-22 12:01:15 +00:00
|
|
|
|
}
|
|
|
|
|
if (!isbackground) return;
|
|
|
|
|
|
|
|
|
|
TString& rwd = (TString&)(*_bg)[rw];
|
|
|
|
|
|
1994-09-13 16:43:52 +00:00
|
|
|
|
while (ch = rwd[cnt++])
|
|
|
|
|
{
|
1997-05-28 12:49:40 +00:00
|
|
|
|
if (!fink_mode && (ch == 'v' || ch == 'o' || ch == 'u' || ch == 'h' || ch == 'r'))
|
|
|
|
|
continue;
|
1994-09-13 16:43:52 +00:00
|
|
|
|
switch(ch)
|
|
|
|
|
{
|
|
|
|
|
case 'v': // verticale intera
|
1995-03-22 09:07:04 +00:00
|
|
|
|
x1 = (byte)rwd[cnt++]-1;
|
|
|
|
|
b.h = e.h = LEN_SPACES(win(), x1)+LEN_SPACES(win(), 1)/2+_hofs;
|
1996-01-03 16:03:08 +00:00
|
|
|
|
b.v = rw * _chary + _vofs; e.v = (rw+1) * _chary + _vofs;
|
1995-03-22 09:07:04 +00:00
|
|
|
|
xvt_dwin_draw_set_pos(win(),b);
|
|
|
|
|
xvt_dwin_draw_line(win(),e);
|
1994-09-13 16:43:52 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'o': // verticale pezzo sopra
|
1995-03-22 09:07:04 +00:00
|
|
|
|
x1 = (byte)rwd[cnt++]-1;
|
|
|
|
|
b.h = e.h = LEN_SPACES(win(), x1)+LEN_SPACES(win(), 1)/2 + _hofs;
|
1996-01-03 16:03:08 +00:00
|
|
|
|
b.v = rw * _chary + _vofs; e.v = rw * _chary + _chary/2 + _vofs;
|
1995-03-22 09:07:04 +00:00
|
|
|
|
xvt_dwin_draw_set_pos(win(),b);
|
|
|
|
|
xvt_dwin_draw_line(win(),e);
|
1994-09-13 16:43:52 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'u': // verticale pezzo sotto
|
1995-03-22 09:07:04 +00:00
|
|
|
|
x1 = (byte)rwd[cnt++]-1;
|
|
|
|
|
b.h = e.h = LEN_SPACES(win(), x1)+LEN_SPACES(win(), 1)/2 + _hofs;
|
1996-01-03 16:03:08 +00:00
|
|
|
|
b.v = rw*_chary + _chary/2 + _vofs; e.v = (rw+1) * _chary + _vofs;
|
1995-03-22 09:07:04 +00:00
|
|
|
|
xvt_dwin_draw_set_pos(win(),b);
|
|
|
|
|
xvt_dwin_draw_line(win(),e);
|
1994-09-13 16:43:52 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'h': // orizzontale intera
|
1995-03-22 09:07:04 +00:00
|
|
|
|
x1 = (byte)rwd[cnt++]-1;
|
|
|
|
|
x2 = (byte)rwd[cnt++]-1;
|
1994-09-13 16:43:52 +00:00
|
|
|
|
b.v = e.v = rw*_chary + _chary/2 + _vofs;
|
1995-03-22 09:07:04 +00:00
|
|
|
|
b.h = LEN_SPACES(win(), x1)+_hofs; e.h = LEN_SPACES(win(), x2)+_hofs;
|
|
|
|
|
xvt_dwin_draw_set_pos(win(),b);
|
|
|
|
|
xvt_dwin_draw_line(win(),e);
|
1994-09-13 16:43:52 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'r': // orizzontale scorciata agli estremi
|
1995-03-22 09:07:04 +00:00
|
|
|
|
x1 = (byte)rwd[cnt++]-1;
|
|
|
|
|
x2 = (byte)rwd[cnt++]-1;
|
1994-09-13 16:43:52 +00:00
|
|
|
|
b.v = e.v = rw*_chary + _chary/2 + _vofs;
|
1995-03-22 09:07:04 +00:00
|
|
|
|
b.h = LEN_SPACES(win(), x1)+LEN_SPACES(win(), 1)/2 + _hofs;
|
|
|
|
|
e.h = LEN_SPACES(win(), x2)+LEN_SPACES(win(), 1)/2+_hofs;
|
|
|
|
|
xvt_dwin_draw_set_pos(win(),b);
|
|
|
|
|
xvt_dwin_draw_line(win(),e);
|
1994-09-13 16:43:52 +00:00
|
|
|
|
break;
|
1995-03-22 09:07:04 +00:00
|
|
|
|
case 'i':
|
|
|
|
|
id = (byte)(rwd[cnt++])-1; // Numero immagine
|
|
|
|
|
y1 = (byte)(rwd[cnt++])-1; // Riga sorgente
|
2002-07-03 14:48:48 +00:00
|
|
|
|
x1 = (byte)(rwd[cnt++])-1; // Colonna sorgente
|
1995-03-22 09:07:04 +00:00
|
|
|
|
x2 = (byte)(rwd[cnt++]); // Larghezza destinazione (in caratteri)
|
|
|
|
|
y2 = (byte)(rwd[cnt++]); // Altezza destinazione (in caratteri)
|
|
|
|
|
if (id >= 0)
|
|
|
|
|
{
|
2002-07-03 14:48:48 +00:00
|
|
|
|
#ifndef XVAGA
|
|
|
|
|
// Ai tempi non veniva in mente un modo peggiore
|
1995-03-22 09:07:04 +00:00
|
|
|
|
const short width = LEN_SPACES(win(), x2); // Larghezza in pixel
|
|
|
|
|
|
|
|
|
|
TImage* i = (TImage*)_images.objptr(id);
|
|
|
|
|
if (i == NULL)
|
|
|
|
|
{
|
1995-04-20 14:35:14 +00:00
|
|
|
|
const TString_array& a = printer().image_names();
|
1995-03-22 09:07:04 +00:00
|
|
|
|
const TImage src(a.row(id));
|
|
|
|
|
if (src.ok())
|
|
|
|
|
{
|
2002-07-03 14:48:48 +00:00
|
|
|
|
// memorizzo l'immagine in risoluzione di stampa! Visto che ho RAM da buttare.
|
|
|
|
|
i = new TImage(src, width, _chary*y2);
|
1995-03-22 09:07:04 +00:00
|
|
|
|
_images.add(i, id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (i && i->ok())
|
|
|
|
|
{
|
|
|
|
|
RCT src; xvt_rect_set(&src, 0, int(_chary*y1),
|
|
|
|
|
width, min(int(_chary*(y1+1)), i->height()));
|
|
|
|
|
if (src.top < i->height())
|
|
|
|
|
{
|
|
|
|
|
PNT p;
|
|
|
|
|
p.h = LEN_SPACES(win(), x1) + _hofs;
|
|
|
|
|
p.v = _chary*rw + _vofs;
|
|
|
|
|
RCT dst = src; xvt_rect_set_pos(&dst, p);
|
|
|
|
|
i->draw(win(), dst, src);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-07-03 14:48:48 +00:00
|
|
|
|
#else
|
|
|
|
|
if (y1 == 0) // Disegno solo una volta per tutte alla prima fetta!
|
|
|
|
|
{
|
|
|
|
|
TImage* i = (TImage*)_images.objptr(id);
|
|
|
|
|
if (i == NULL)
|
|
|
|
|
{
|
|
|
|
|
// memorizzo l'immagine cos<6F> com'<27> alla risoluzione originale!
|
|
|
|
|
const TString_array& a = printer().image_names();
|
|
|
|
|
i = new TImage(a.row(id));
|
|
|
|
|
_images.add(i, id);
|
|
|
|
|
}
|
|
|
|
|
if (i != NULL && i->ok())
|
|
|
|
|
{
|
|
|
|
|
RCT dst;
|
|
|
|
|
dst.left = LEN_SPACES(win(), x1) + _hofs;
|
|
|
|
|
dst.top = _chary*rw + _vofs;
|
|
|
|
|
dst.right = dst.left + LEN_SPACES(win(), x2);
|
|
|
|
|
dst.bottom = dst.top + _chary*y2;
|
|
|
|
|
i->draw(win(), dst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
1995-03-22 09:07:04 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
1994-09-13 16:43:52 +00:00
|
|
|
|
case 'W':
|
|
|
|
|
curwid = rwd[cnt++];
|
|
|
|
|
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
|
|
|
|
|
trans_pen(curpen));
|
|
|
|
|
break;
|
|
|
|
|
case 'P':
|
|
|
|
|
curpen = rwd[cnt++];
|
|
|
|
|
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
|
|
|
|
|
trans_pen(curpen));
|
|
|
|
|
break;
|
|
|
|
|
case 'B':
|
|
|
|
|
curpat = rwd[cnt++];
|
|
|
|
|
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
|
|
|
|
|
trans_pen(curpen));
|
|
|
|
|
break;
|
|
|
|
|
case 'C':
|
|
|
|
|
curcol = rwd[cnt++];
|
|
|
|
|
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
|
|
|
|
|
trans_pen(curpen));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// restore default pen
|
|
|
|
|
set_pen(COLOR_BLACK);
|
1999-05-24 13:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TPrintwin::paint_image(int row, const char* cp)
|
|
|
|
|
{
|
|
|
|
|
TToken_string tok(cp+2, ',');
|
|
|
|
|
TImage img(tok.get(0));
|
|
|
|
|
|
|
|
|
|
const int x = _hofs + LEN_SPACES(win(), tok.get_int()-1);
|
|
|
|
|
const int y = _vofs + row * _chary;
|
|
|
|
|
|
|
|
|
|
int dx = LEN_SPACES(win(), tok.get_int(3)-tok.get_int(1)+1);
|
|
|
|
|
int dy = _chary * (tok.get_int(4)-tok.get_int(2)+1);
|
|
|
|
|
if (img.ok())
|
|
|
|
|
{
|
|
|
|
|
const double ratiox = double(img.width()) / dx;
|
|
|
|
|
const double ratioy = double(img.height()) / dy;
|
|
|
|
|
const double ratio = ratiox > ratioy ? ratiox : ratioy;
|
|
|
|
|
dx = int(img.width() / ratio);
|
|
|
|
|
dy = int(img.height() / ratio);
|
|
|
|
|
RCT dst; xvt_rect_set(&dst, x, y, x+dx, y+dy);
|
|
|
|
|
img.draw(win(), dst);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RCT dst; xvt_rect_set(&dst, x, y, x+dx, y+dy);
|
|
|
|
|
set_pen(COLOR_RED);
|
|
|
|
|
xvt_dwin_draw_rect(win(), &dst);
|
|
|
|
|
}
|
1994-09-13 16:43:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-24 13:34:11 +00:00
|
|
|
|
|
1994-09-13 16:43:52 +00:00
|
|
|
|
void TPrintwin::paint_row(long j)
|
|
|
|
|
{
|
1995-05-10 15:40:06 +00:00
|
|
|
|
const int row = (int)(j % _formlen);
|
1996-10-08 11:09:29 +00:00
|
|
|
|
const int y = row*_chary + _chary - _descent + ((_chary == 1) ? 0 : _vofs);
|
1994-11-03 09:03:14 +00:00
|
|
|
|
|
1999-10-22 10:00:18 +00:00
|
|
|
|
paint_background(j);
|
|
|
|
|
|
|
|
|
|
if (_chary > 1)
|
1995-09-14 14:25:30 +00:00
|
|
|
|
{
|
|
|
|
|
_txt.read_line(j);
|
|
|
|
|
|
|
|
|
|
int pos = 0;
|
|
|
|
|
|
|
|
|
|
const char* cp;
|
|
|
|
|
while((cp = _txt.piece()) != NULL)
|
|
|
|
|
{
|
|
|
|
|
const int st = _txt.get_style();
|
|
|
|
|
const COLOR bg = trans_color(_txt.get_background());
|
|
|
|
|
const COLOR fg = trans_color(_txt.get_foreground());
|
|
|
|
|
set_color(fg, bg);
|
1995-06-15 13:51:47 +00:00
|
|
|
|
|
1999-05-24 13:34:11 +00:00
|
|
|
|
if (bg != fg) // Testo vero
|
|
|
|
|
{
|
|
|
|
|
set_color(fg, bg);
|
2002-07-03 14:48:48 +00:00
|
|
|
|
set_font(printer().fontname(), st, _char_size);
|
1995-09-14 14:25:30 +00:00
|
|
|
|
|
1999-05-24 13:34:11 +00:00
|
|
|
|
const char* beg = cp;
|
|
|
|
|
while (*beg)
|
|
|
|
|
{
|
|
|
|
|
for (; *beg == ' '; beg++) // Salta spazi iniziali
|
|
|
|
|
pos++;
|
|
|
|
|
|
|
|
|
|
if (*beg)
|
|
|
|
|
{
|
|
|
|
|
int len = 0;
|
|
|
|
|
for (const char * end = beg; *end && (*end != ' ' || *(end+1) != ' '); end++)
|
|
|
|
|
len++; // Misura stringa da stampare
|
|
|
|
|
xvt_dwin_draw_text(win(), _hofs + LEN_SPACES(win(), pos), y, (char*)beg, len);
|
|
|
|
|
pos += len;
|
|
|
|
|
beg = end;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // Testo trasparente (elementi grafici aggiuntivi)
|
|
|
|
|
{
|
|
|
|
|
if (*cp == 'i')
|
|
|
|
|
paint_image(row, cp);
|
1995-09-14 14:25:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1996-07-17 14:10:41 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
1995-09-14 14:25:30 +00:00
|
|
|
|
{
|
|
|
|
|
set_font(printer().fontname(), XVT_FS_NONE, _char_size);
|
2003-05-26 13:02:42 +00:00
|
|
|
|
#if XVT_OS == XVT_OS_WIN32
|
1996-07-17 14:10:41 +00:00
|
|
|
|
// Questa e' la patch per TTY.DRV.
|
1997-09-25 16:35:38 +00:00
|
|
|
|
if (j > 0 && (j % _realformlen) == 0)
|
1996-07-17 14:10:41 +00:00
|
|
|
|
{
|
1996-10-07 11:11:23 +00:00
|
|
|
|
_frlc++;
|
1997-09-25 16:35:38 +00:00
|
|
|
|
xvt_dwin_draw_text(win(), 0, y , "", -1);
|
1997-09-26 08:37:29 +00:00
|
|
|
|
}
|
1996-07-17 14:10:41 +00:00
|
|
|
|
else
|
|
|
|
|
#endif
|
1998-02-24 10:37:28 +00:00
|
|
|
|
xvt_dwin_draw_text(win(), 0, y, (char*)(const char*)_txt.line(j - _frlc), -1);
|
1994-09-13 16:43:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
|
// @doc INTERNAL
|
1996-10-08 11:09:29 +00:00
|
|
|
|
|
1995-10-20 18:27:01 +00:00
|
|
|
|
// @mfunc Permette di stampare un rettangolo a video
|
|
|
|
|
//
|
|
|
|
|
// @rdesc Ritorna se e' riuscito a stampare in una unica pagina
|
|
|
|
|
bool TPrintwin::print_band(
|
2003-05-15 08:09:47 +00:00
|
|
|
|
int page, // @parm Numero della pagina da stampare
|
2002-02-28 11:35:23 +00:00
|
|
|
|
const RCT& r) // @parm Parte di finestra da stampare
|
1994-09-13 16:43:52 +00:00
|
|
|
|
|
1995-10-20 18:27:01 +00:00
|
|
|
|
// @comm Di solito viene disegnata l'intera pagina, ma la cosa dipende dal driver di stampa
|
1994-09-13 16:43:52 +00:00
|
|
|
|
{
|
1996-10-08 11:09:29 +00:00
|
|
|
|
// int i,l_ofst = printer().get_line_offset();
|
|
|
|
|
// const int offset = l_ofst < 0 ? abs(l_ofst) + 1: 0;
|
1997-09-26 08:37:29 +00:00
|
|
|
|
// const int offset = printer().get_line_offset();
|
|
|
|
|
// const bool generic = _chary == 1;
|
1996-09-02 14:18:13 +00:00
|
|
|
|
|
2003-05-15 08:09:47 +00:00
|
|
|
|
const long first_row = (long)page * _formlen;
|
1995-03-22 09:07:04 +00:00
|
|
|
|
const int rows = (r.bottom - r.top) / _chary;
|
1997-09-26 08:37:29 +00:00
|
|
|
|
const int top = r.top / _chary;
|
2003-05-15 08:09:47 +00:00
|
|
|
|
const long lines = _txt.lines() + _frlc;
|
1997-09-26 08:37:29 +00:00
|
|
|
|
|
1994-09-13 16:43:52 +00:00
|
|
|
|
for (int k = top; k < top+rows; k++)
|
|
|
|
|
{
|
2003-05-15 08:09:47 +00:00
|
|
|
|
const long row = first_row + k;
|
|
|
|
|
if (row < lines && k < _formlen)
|
1997-09-26 08:37:29 +00:00
|
|
|
|
paint_row(row);
|
1996-10-07 11:11:23 +00:00
|
|
|
|
else
|
|
|
|
|
break;
|
1994-09-13 16:43:52 +00:00
|
|
|
|
}
|
2003-05-15 08:09:47 +00:00
|
|
|
|
return (first_row + k < lines);
|
2002-02-28 11:35:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
|
// @doc INTERNAL
|
|
|
|
|
|
1995-10-20 18:27:01 +00:00
|
|
|
|
// @mfunc Inizia la stampa
|
|
|
|
|
//
|
|
|
|
|
// @rdesc Ritorna se viene interrotta la stampa:
|
|
|
|
|
//
|
|
|
|
|
// @flag TRUE | La stampa e' andata a buon fine
|
|
|
|
|
// @flag FALSE | La stampa e' stata interrotta
|
2003-05-15 08:09:47 +00:00
|
|
|
|
bool TPrintwin::do_print(word page_from, word page_to, word copies)
|
2002-02-28 11:35:23 +00:00
|
|
|
|
// @comm Quando possibile parte un processo concorrente (dipende dal sistema operativo)
|
2003-05-15 08:09:47 +00:00
|
|
|
|
{
|
|
|
|
|
CHECKD(page_from > 0, "Invalid page start ", page_from);
|
|
|
|
|
CHECKD(copies > 0, "Invalid number of copies ", copies);
|
|
|
|
|
|
1996-10-08 11:09:29 +00:00
|
|
|
|
_frlc = 0;
|
|
|
|
|
_blank_lines_to_print = 0;
|
2002-02-28 11:35:23 +00:00
|
|
|
|
|
2003-05-15 08:09:47 +00:00
|
|
|
|
for (word c = 0; c < copies && !_aborted; c++)
|
1994-09-13 16:43:52 +00:00
|
|
|
|
{
|
2003-05-15 08:09:47 +00:00
|
|
|
|
bool finished = FALSE;
|
|
|
|
|
for (word page = page_from-1; !finished && !_aborted; page++)
|
1995-04-06 15:28:37 +00:00
|
|
|
|
{
|
2003-05-15 08:09:47 +00:00
|
|
|
|
if (page_to >= page_from && page >= page_to)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
_aborted = xvt_print_open_page(_printrcd) == 0;
|
|
|
|
|
if (!_aborted)
|
|
|
|
|
{
|
|
|
|
|
for (const RCT* rct = xvt_print_get_next_band(); rct != NULL; rct = xvt_print_get_next_band())
|
|
|
|
|
{
|
|
|
|
|
set_font(XVT_FFN_SYSTEM, XVT_FS_NONE, _char_size); // ???
|
|
|
|
|
set_font(printer().fontname(), XVT_FS_NONE, _char_size);
|
|
|
|
|
LEN_SPACES(win(), -1); // Resetta bene le dimensioni font
|
|
|
|
|
if (!print_band(page, *rct))
|
|
|
|
|
{
|
|
|
|
|
finished = TRUE;
|
|
|
|
|
while (xvt_print_get_next_band()); // Esce dalla lista delle bande
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_aborted = xvt_print_close_page(_printrcd) == 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-28 11:35:23 +00:00
|
|
|
|
|
|
|
|
|
return !_aborted;
|
1995-04-06 15:28:37 +00:00
|
|
|
|
}
|
1994-09-13 16:43:52 +00:00
|
|
|
|
|
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
|
TPrintwin::TPrintwin(TTextfile& txt)
|
|
|
|
|
: _txt(txt), _inited(FALSE), _aborted(FALSE)
|
1994-09-13 16:43:52 +00:00
|
|
|
|
{
|
1995-04-20 14:35:14 +00:00
|
|
|
|
TPrinter& p = printer();
|
1994-09-13 16:43:52 +00:00
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
|
_printrcd = p.get_printrcd();
|
1998-02-24 10:37:28 +00:00
|
|
|
|
if (!xvt_print_is_valid(_printrcd))
|
|
|
|
|
{
|
|
|
|
|
_aborted = TRUE;
|
|
|
|
|
return;
|
|
|
|
|
}
|
1995-03-22 09:07:04 +00:00
|
|
|
|
|
|
|
|
|
WINDOW prwin = xvt_print_create_win(_printrcd, (char*)(const char*)main_app().title());
|
1995-05-10 15:40:06 +00:00
|
|
|
|
if (prwin == NULL_WIN)
|
|
|
|
|
{
|
|
|
|
|
_aborted = TRUE;
|
|
|
|
|
return;
|
|
|
|
|
}
|
1995-03-22 09:07:04 +00:00
|
|
|
|
set_win(prwin);
|
1995-05-10 15:40:06 +00:00
|
|
|
|
|
1995-04-06 15:28:37 +00:00
|
|
|
|
_char_size = p.get_char_size();
|
1995-05-10 15:40:06 +00:00
|
|
|
|
set_font(p.fontname(), XVT_FS_NONE, _char_size);
|
|
|
|
|
LEN_SPACES(win(), -1); // force update
|
1996-10-08 11:09:29 +00:00
|
|
|
|
|
|
|
|
|
_pagelen = p.formlen();
|
1998-02-24 10:37:28 +00:00
|
|
|
|
|
|
|
|
|
p.init_formlen(prwin); // Calcola offset e altre misure pagina
|
1996-01-03 16:03:08 +00:00
|
|
|
|
|
|
|
|
|
int abs_column=p.get_column_offset();
|
|
|
|
|
int segno = abs_column>=0 ? 1 : -1;
|
|
|
|
|
abs_column*=segno;
|
1995-05-10 15:40:06 +00:00
|
|
|
|
xvt_dwin_get_font_metrics(prwin, &_lead, &_ascent, &_descent);
|
|
|
|
|
_bg = &p.getbgdesc();
|
|
|
|
|
_chary = p.get_dots_per_line();
|
1996-01-03 16:03:08 +00:00
|
|
|
|
_hofs = p.get_horz_offset() + segno*LEN_SPACES(prwin,abs_column);
|
|
|
|
|
_vofs = p.get_vert_offset() + p.get_line_offset()*_chary;
|
1996-10-08 11:09:29 +00:00
|
|
|
|
|
1995-05-10 15:40:06 +00:00
|
|
|
|
_formlen = p.formlen();
|
1996-10-08 11:09:29 +00:00
|
|
|
|
p.formlen(_pagelen);
|
1995-10-27 08:28:13 +00:00
|
|
|
|
|
|
|
|
|
if (p.is_generic())
|
|
|
|
|
{
|
|
|
|
|
long pw, ph, phr, pvr; // Printer width, height, horizontal and vertical resolution
|
|
|
|
|
xvt_app_escape (XVT_ESC_GET_PRINTER_INFO, p.get_printrcd(), &ph, &pw, &pvr, &phr);
|
|
|
|
|
if (pvr != 0)
|
|
|
|
|
_realformlen = int(ph * p.get_lines_per_inch() / pvr);
|
|
|
|
|
else
|
|
|
|
|
_realformlen = 66;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
_realformlen = 66; // Anche se non e' importante settarlo in altri casi.
|
1995-05-10 15:40:06 +00:00
|
|
|
|
_formwidth = p.formwidth();
|
|
|
|
|
_inited = TRUE;
|
1994-09-13 16:43:52 +00:00
|
|
|
|
}
|
1995-03-22 09:07:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TPrintwin::~TPrintwin()
|
|
|
|
|
{
|
|
|
|
|
if (_inited && win() != NULL_WIN)
|
|
|
|
|
xvt_vobj_destroy(win());
|
|
|
|
|
set_win(NULL_WIN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|