Eliminati errori di allineamento stampe

Eliminato XVT INTERNAL ERROR al Cancel della stampa


git-svn-id: svn://10.65.10.50/trunk@511 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1994-11-03 09:03:14 +00:00
parent 9f80c0bc3c
commit 96404663d4
3 changed files with 258 additions and 240 deletions

View File

@ -2,6 +2,14 @@
#include <xvtility.h> #include <xvtility.h>
#include <applicat.h> #include <applicat.h>
static char __spc[] = " "
" "
" "
" "
" "
" ";
#define LEN_SPACES(x) (win_get_text_width(win(),__spc,x))
void TPrintwin::paint_background(long j) void TPrintwin::paint_background(long j)
{ {
@ -23,21 +31,21 @@ void TPrintwin::paint_background(long j)
{ {
case 'v': // verticale intera case 'v': // verticale intera
x1 = (unsigned char)rwd[cnt++]-1; x1 = (unsigned char)rwd[cnt++]-1;
b.h = e.h = x1*_charx+_charx/2+_hofs; b.h = e.h = LEN_SPACES(x1)+LEN_SPACES(1)/2+_hofs;
b.v = rw * _chary + _vofs; e.v = rw * _chary + _vofs; b.v = rw * _chary + _vofs; e.v = rw * _chary + _vofs;
win_move_to(win(),b); win_move_to(win(),b);
win_draw_line(win(),e); win_draw_line(win(),e);
break; break;
case 'o': // verticale pezzo sopra case 'o': // verticale pezzo sopra
x1 = (unsigned char)rwd[cnt++]-1; x1 = (unsigned char)rwd[cnt++]-1;
b.h = e.h = x1*_charx+_charx/2 + _hofs; b.h = e.h = LEN_SPACES(x1)+LEN_SPACES(1)/2 + _hofs;
b.v = rw * _chary + _vofs; e.v = rw * _chary - _chary/2 + _vofs; b.v = rw * _chary + _vofs; e.v = rw * _chary - _chary/2 + _vofs;
win_move_to(win(),b); win_move_to(win(),b);
win_draw_line(win(),e); win_draw_line(win(),e);
break; break;
case 'u': // verticale pezzo sotto case 'u': // verticale pezzo sotto
x1 = (unsigned char)rwd[cnt++]-1; x1 = (unsigned char)rwd[cnt++]-1;
b.h = e.h = x1*_charx+_charx/2 + _hofs; b.h = e.h = LEN_SPACES(x1)+LEN_SPACES(1)/2 + _hofs;
b.v = rw*_chary + _chary/2 + _vofs; e.v = rw * _chary + _vofs; b.v = rw*_chary + _chary/2 + _vofs; e.v = rw * _chary + _vofs;
win_move_to(win(),b); win_move_to(win(),b);
win_draw_line(win(),e); win_draw_line(win(),e);
@ -46,7 +54,7 @@ void TPrintwin::paint_background(long j)
x1 = (unsigned char)rwd[cnt++]-1; x1 = (unsigned char)rwd[cnt++]-1;
x2 = (unsigned char)rwd[cnt++]-1; x2 = (unsigned char)rwd[cnt++]-1;
b.v = e.v = rw*_chary + _chary/2 + _vofs; b.v = e.v = rw*_chary + _chary/2 + _vofs;
b.h = x1*_charx+_hofs; e.h = x2*_charx + _hofs; b.h = LEN_SPACES(x1)+_hofs; e.h = LEN_SPACES(x2)+_hofs;
win_move_to(win(),b); win_move_to(win(),b);
win_draw_line(win(),e); win_draw_line(win(),e);
break; break;
@ -54,7 +62,8 @@ void TPrintwin::paint_background(long j)
x1 = (unsigned char)rwd[cnt++]-1; x1 = (unsigned char)rwd[cnt++]-1;
x2 = (unsigned char)rwd[cnt++]-1; x2 = (unsigned char)rwd[cnt++]-1;
b.v = e.v = rw*_chary + _chary/2 + _vofs; b.v = e.v = rw*_chary + _chary/2 + _vofs;
b.h = x1*_charx+_charx/2 + _hofs; e.h = x2*_charx+_charx/2+_hofs; b.h = LEN_SPACES(x1)+LEN_SPACES(1)/2 + _hofs;
e.h = LEN_SPACES(x2)+LEN_SPACES(1)/2+_hofs;
win_move_to(win(),b); win_move_to(win(),b);
win_draw_line(win(),e); win_draw_line(win(),e);
break; break;
@ -88,11 +97,18 @@ void TPrintwin::paint_background(long j)
void TPrintwin::paint_row(long j) void TPrintwin::paint_row(long j)
{ {
static char line[257];
const char* cp; int pos = 0; const char* cp; int pos = 0;
int pixpos = 0;
int row = (int)(j % _formlen); int row = (int)(j % _formlen);
strcpy(line,_txt.line(j));
_txt.read_line(j); _txt.read_line(j);
while(cp = _txt.piece()) while(cp = _txt.piece())
{ {
pos += strlen(cp);
#if XVT_OS != XVT_OS_SCOUNIX #if XVT_OS != XVT_OS_SCOUNIX
int st = _txt.get_style(); int st = _txt.get_style();
long bg = trans_color(_txt.get_background()); long bg = trans_color(_txt.get_background());
@ -102,7 +118,7 @@ void TPrintwin::paint_row(long j)
#else #else
set_color(COLOR_BLACK, COLOR_WHITE); set_color(COLOR_BLACK, COLOR_WHITE);
#endif #endif
win_draw_text(win(), pos*_charx + _hofs, row*_chary + _chary + _vofs - _descent, win_draw_text(win(), pixpos+_hofs, row*_chary + _chary + _vofs - _descent,
(char *)cp, -1); (char *)cp, -1);
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
if (st & underlined) if (st & underlined)
@ -110,13 +126,13 @@ void TPrintwin::paint_row(long j)
PNT b, e; PNT b, e;
set_pen(COLOR_BLACK); set_pen(COLOR_BLACK);
b.h = _charx*pos + _hofs; b.v = row*_chary + _chary + _vofs; b.h = pixpos + _hofs; b.v = row*_chary + _chary + _vofs;
e.h = _charx*(pos+strlen(cp)) + _hofs; e.v = b.v; e.h = (pixpos+win_get_text_width(win(), line, pos)) + _hofs; e.v = b.v;
win_move_to (win(),b); win_move_to (win(),b);
win_draw_line(win(),e); win_draw_line(win(),e);
} }
#endif #endif
pos += strlen(cp); pixpos = win_get_text_width(win(), line, pos);
} }
paint_background(j); paint_background(j);
} }
@ -158,16 +174,17 @@ bool TPrintwin::do_print()
TPrintwin::~TPrintwin() TPrintwin::~TPrintwin()
{ {
close_print_window(win(), _printrcd); if (_inited && win() != NULL_WIN) close_print_window(win(), _printrcd);
set_win(NULL_WIN); set_win(NULL_WIN);
} }
TPrintwin::TPrintwin(PRINT_RCD* p, TTextfile& txt, int chsz) : TPrintwin::TPrintwin(PRINT_RCD* p, TTextfile& txt, int chsz) :
_printrcd(p), _aborted(FALSE), _txt(txt), _char_size(chsz) _printrcd(p), _aborted(FALSE), _txt(txt), _char_size(chsz), _inited(FALSE)
{ {
WINDOW w = new_print_window(_printrcd, (char*)(const char*)main_app().title()); WINDOW w = new_print_window(_printrcd, (char*)(const char*)main_app().title());
set_win(w); set_win(w);
_inited = TRUE;
if (w != NULL_WIN) if (w != NULL_WIN)
{ {
_bg = main_app().printer().getbgdesc(); _bg = main_app().printer().getbgdesc();
@ -177,13 +194,13 @@ _printrcd(p), _aborted(FALSE), _txt(txt), _char_size(chsz)
set_font(FF_SYSTEM,0,_char_size); set_font(FF_SYSTEM,0,_char_size);
win_get_font_metrics(win(), &_lead, &_ascent, &_descent); win_get_font_metrics(win(), &_lead, &_ascent, &_descent);
_charx = win_get_text_width(win(), "MM", -1) - win_get_text_width(win(), "M", -1);
_chary = main_app().printer().get_dots_per_line(); _chary = main_app().printer().get_dots_per_line();
RCT rct; get_client_rect(win(),&rct); RCT rct; get_client_rect(win(),&rct);
_vofs = main_app().printer().get_vert_offset(); _vofs = main_app().printer().get_vert_offset();
_hofs = (rct.right - rct.left) % _charx; _hofs = (rct.right - rct.left) % LEN_SPACES(1);
} }
else _aborted = TRUE; else _aborted = TRUE;
} }

View File

@ -26,8 +26,9 @@ class TPrintwin : public TWindow
int _lead, _ascent, _descent; int _lead, _ascent, _descent;
int _hofs, _vofs; int _hofs, _vofs;
int _charx, _chary; int _chary;
int _char_size; int _char_size;
bool _inited;
void paint_background(long j); void paint_background(long j);
void paint_row(long j); void paint_row(long j);