Patch level : 2.0 nopatch

Files correlati     : stampe
Ricompilazione Demo : [ ]
Commento            :

Aggiunta finestra di conferma prima di ogni stampa su carta:
e' possibile anche impostare le pagine ed il numero di copie desiderate

Corretta nei form la stampa di testi su piu' righe con prompt sulla prima


git-svn-id: svn://10.65.10.50/trunk@11132 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2003-05-15 08:09:47 +00:00
parent 1d58e346bb
commit bb631844ef
7 changed files with 113 additions and 107 deletions

View File

@ -32,7 +32,7 @@ COLOR DISABLED_COLOR = COLOR_DKGRAY;
COLOR DISABLED_BACK_COLOR = MASK_BACK_COLOR; COLOR DISABLED_BACK_COLOR = MASK_BACK_COLOR;
COLOR FOCUS_COLOR = NORMAL_COLOR; COLOR FOCUS_COLOR = NORMAL_COLOR;
COLOR FOCUS_BACK_COLOR = COLOR_YELLOW; COLOR FOCUS_BACK_COLOR = COLOR_YELLOW;
COLOR REQUIRED_BACK_COLOR = MAKE_COLOR(255,255,216); COLOR REQUIRED_BACK_COLOR = MAKE_COLOR(255,255,156);
bool CAMPI_SCAVATI = TRUE; bool CAMPI_SCAVATI = TRUE;
bool AUTOSELECT = FALSE; bool AUTOSELECT = FALSE;

View File

@ -1074,28 +1074,15 @@ void TForm_string::put_paragraph(const char* s)
if (h > 1) if (h > 1)
{ {
/* TString lines;
const int w = width(); if (_prompt.not_empty())
TParagraph_string p(s, w); lines = _prompt;
int i = _prompt.not_empty() ? 1 : 0; lines << s;
for (; (s = p.get()) != NULL && i < h; i++) TParagraph_string p(lines, width());
for (int i=0; (s = p.get()) != NULL && i < h; i++)
string_at(x(), _y+i, s); string_at(x(), _y+i, s);
_effective_height = i; _effective_height = i;
*/
const int w = width();
int plen=_prompt.len();
TString prompt(plen,'-');
TParagraph_string p(prompt << s, w);
#ifdef DBG
if (plen>0 && *s)
NFCHECK("Nei form la stampa di un item su più righe con prompt ora non pone più il prompt isolato sulla prima riga ma allinea a sinistra del prompt ");
#endif
for (int i=0; (s = p.get()) != NULL && i < h; i++)
{
string_at(x()+plen, _y+i, s+plen);
}
_effective_height = i;
TForm_subsection *subsec= section().subsection_above(); TForm_subsection *subsec= section().subsection_above();
if (subsec) if (subsec)
{ {

View File

@ -11,6 +11,7 @@
#include <agasys.h> #include <agasys.h>
#include <bagn001a.h> #include <bagn001a.h>
#include <bagn003.h>
HIDDEN TPrinter* _printer = NULL; HIDDEN TPrinter* _printer = NULL;
@ -189,23 +190,59 @@ void TPrint_intersector::clear()
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// PrDesc // TPrint_txt_info
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
struct PrDesc struct TPrint_txt_info
{ {
TTextfile *_txt; TTextfile* _txt;
TPrinter * _p; word _copies;
} PrintWhat; word _pagefrom;
word _pageto;
bool edit();
TPrint_txt_info(TTextfile& txt);
};
bool TPrint_txt_info::edit()
{
TPrinter& p = printer();
TMask msk("bagn003");
msk.set(F_PRINTER, p.printername());
msk.set(F_FONT, p.fontname());
msk.set(F_SIZE, p.get_char_size());
msk.set(F_ISGRAPHICS, p.isgraphics() ? "X" : "");
msk.set(F_FROMPAGE, _pagefrom);
msk.set(F_TOPAGE, _pageto);
msk.set(F_COPIES, _copies);
bool ok = msk.run() == K_ENTER;
if (ok)
{
_copies = msk.get_int(F_COPIES);
_pagefrom = msk.get_int(F_FROMPAGE);
_pageto = msk.get_int(F_TOPAGE);
}
return ok;
}
TPrint_txt_info::TPrint_txt_info(TTextfile& txt)
: _txt(&txt), _copies(1), _pagefrom(1), _pageto(0)
{
const word ps = txt.page_size();
const long li = txt.lines();
_pageto = (li+ps-1) / ps;
}
BOOLEAN TPrinter::start_print(long data) BOOLEAN TPrinter::start_print(long data)
{ {
const PrDesc *pd = (PrDesc *) data; const TPrint_txt_info *pd = (TPrint_txt_info *) data;
TTextfile& txt = *(pd->_txt); TTextfile& txt = *(pd->_txt);
const int vofs = pd->_p->get_line_offset(); TPrinter& stampante = printer();
const int hofs = pd->_p->get_column_offset();
if (pd->_p->is_generic() && (vofs != 0 || hofs != 0)) const int vofs = stampante.get_line_offset();
const int hofs = stampante.get_column_offset();
if (stampante.is_generic() && (vofs != 0 || hofs != 0))
{ {
TTextfile new_txt; TTextfile new_txt;
TString s(256); TString s(256);
@ -214,7 +251,7 @@ BOOLEAN TPrinter::start_print(long data)
for (long row = (vofs < 0 ? -vofs : 0); row < last_row; row++) for (long row = (vofs < 0 ? -vofs : 0); row < last_row; row++)
{ {
const int pagelen = pd->_p->formlen(); const int pagelen = stampante.formlen();
const int page_row = (int) (out_row % pagelen); const int page_row = (int) (out_row % pagelen);
if (vofs > 0 && page_row == 0) if (vofs > 0 && page_row == 0)
@ -248,14 +285,14 @@ BOOLEAN TPrinter::start_print(long data)
out_row++; out_row++;
} }
TPrintwin pw(new_txt); TPrintwin pw(new_txt);
pw.do_print(); pw.do_print(pd->_pagefrom, pd->_pageto, pd->_copies);
return pw.aborted(); return pw.aborted();
} }
else else
{ {
TPrintwin pw(txt); TPrintwin pw(txt);
if (pw.win() != NULL_WIN) if (pw.win() != NULL_WIN)
pw.do_print(); pw.do_print(pd->_pagefrom, pd->_pageto, pd->_copies);
return pw.aborted(); return pw.aborted();
} }
} }
@ -1032,7 +1069,7 @@ void TPrinter::read_configuration(
if (iniptr == NULL) if (iniptr == NULL)
iniptr = new TConfig(CONFIG_USER, "Printer"); iniptr = new TConfig(CONFIG_USER, "Printer");
const int what = iniptr->get_int("Type", NULL, -1, 0); // Tipo stampante const int what = iniptr->get_int("Type", NULL, -1, 4); // Tipo stampante
_prname = iniptr->get("Name", NULL, -1, _defPrinter); // Nome stampante corrente _prname = iniptr->get("Name", NULL, -1, _defPrinter); // Nome stampante corrente
_printerfile = iniptr->get("File", NULL, -1, ""); // File di stampa _printerfile = iniptr->get("File", NULL, -1, ""); // File di stampa
_fontname = iniptr->get("Font", NULL, -1, XVT_FFN_FIXED); // Nome del font _fontname = iniptr->get("Font", NULL, -1, XVT_FFN_FIXED); // Nome del font
@ -1692,11 +1729,13 @@ void TPrinter::print_txt(TTextfile& txt)
{ {
if (txt.lines() > 0) if (txt.lines() > 0)
{ {
PrintWhat._txt = &txt; TPrint_txt_info what(txt);
PrintWhat._p = this; if (what.edit())
xvt_print_open(); {
xvt_print_start_thread(start_print, (long) (&PrintWhat)); xvt_print_open();
xvt_print_close(); xvt_print_start_thread(start_print, long(&what));
xvt_print_close();
}
/* /*
if (is_generic()) if (is_generic())
os_spool_row("\n"); // Force flushing on Generic printer os_spool_row("\n"); // Force flushing on Generic printer

View File

@ -5,31 +5,21 @@
HIDDEN int LEN_SPACES(WINDOW win, int x) HIDDEN int LEN_SPACES(WINDOW win, int x)
{ {
HIDDEN long w = 0L; HIDDEN int w = 0L;
const int columns = 132;
if (x < 0) if (x < 0)
{ {
x = 80; x = columns;
w = 0L; w = 0L;
} }
if (w == 0L) if (w == 0L)
{ {
TString256 spc; spc.fill('m', 132); TString256 spc; spc.fill('m', columns);
w = xvt_dwin_get_text_width(win, spc.get_buffer(), 132); w = xvt_dwin_get_text_width(win, spc.get_buffer(), columns);
} }
const int k = int((w*x) / 132); const int tab = w * x / columns;
return tab;
#if defined(DBG) && !defined(XVAGA)
static bool error_on = TRUE;
if (error_on)
{
TString256 spc; spc.fill('m', x);
const int k1 = xvt_dwin_get_text_width(win, spc.get_buffer(), x);
if (k != k1)
error_on = error_box("Maguire disagrees: %d != %d", k, k1);
}
#endif
return k;
} }
void TPrintwin::paint_background(long j) void TPrintwin::paint_background(long j)
@ -293,7 +283,7 @@ void TPrintwin::paint_row(long j)
// //
// @rdesc Ritorna se e' riuscito a stampare in una unica pagina // @rdesc Ritorna se e' riuscito a stampare in una unica pagina
bool TPrintwin::print_band( bool TPrintwin::print_band(
int page, // @parm Numero della pagina in cui stampare int page, // @parm Numero della pagina da stampare
const RCT& r) // @parm Parte di finestra da stampare const RCT& r) // @parm Parte di finestra da stampare
// @comm Di solito viene disegnata l'intera pagina, ma la cosa dipende dal driver di stampa // @comm Di solito viene disegnata l'intera pagina, ma la cosa dipende dal driver di stampa
@ -303,32 +293,22 @@ bool TPrintwin::print_band(
// const int offset = printer().get_line_offset(); // const int offset = printer().get_line_offset();
// const bool generic = _chary == 1; // const bool generic = _chary == 1;
const long j = ((long)page) * _formlen; const long first_row = (long)page * _formlen;
const int rows = (r.bottom - r.top) / _chary; const int rows = (r.bottom - r.top) / _chary;
const int top = r.top / _chary; const int top = r.top / _chary;
const long lines = _txt.lines() + _frlc;
for (int k = top; k < top+rows; k++) for (int k = top; k < top+rows; k++)
{ {
long row = j + k; const long row = first_row + k;
if (row < lines && k < _formlen)
if (row < _txt.lines() + _frlc && k < _formlen)
paint_row(row); paint_row(row);
else else
break; break;
} }
return (j + k < _txt.lines() + _frlc); return (first_row + k < lines);
} }
#ifdef XVAGA
TPrintwin* _curr_print = NULL;
bool print_callback(int page, const RCT& rct)
{
return _curr_print->print_band(page-1, rct);
}
#endif
// @doc INTERNAL // @doc INTERNAL
// @mfunc Inizia la stampa // @mfunc Inizia la stampa
@ -337,30 +317,40 @@ bool print_callback(int page, const RCT& rct)
// //
// @flag TRUE | La stampa e' andata a buon fine // @flag TRUE | La stampa e' andata a buon fine
// @flag FALSE | La stampa e' stata interrotta // @flag FALSE | La stampa e' stata interrotta
bool TPrintwin::do_print() bool TPrintwin::do_print(word page_from, word page_to, word copies)
// @comm Quando possibile parte un processo concorrente (dipende dal sistema operativo) // @comm Quando possibile parte un processo concorrente (dipende dal sistema operativo)
{ {
CHECKD(page_from > 0, "Invalid page start ", page_from);
CHECKD(copies > 0, "Invalid number of copies ", copies);
_frlc = 0; _frlc = 0;
_blank_lines_to_print = 0; _blank_lines_to_print = 0;
bool finished = FALSE; for (word c = 0; c < copies && !_aborted; c++)
for (int page = 0; !finished && !_aborted; page++)
{ {
_aborted = xvt_print_open_page(_printrcd) == 0; bool finished = FALSE;
if (!_aborted) for (word page = page_from-1; !finished && !_aborted; page++)
{ {
for (const RCT* rct = xvt_print_get_next_band(); rct != NULL; rct = xvt_print_get_next_band()) if (page_to >= page_from && page >= page_to)
{ break;
set_font(XVT_FFN_SYSTEM, XVT_FS_NONE, _char_size); // ???
set_font(printer().fontname(), XVT_FS_NONE, _char_size); _aborted = xvt_print_open_page(_printrcd) == 0;
LEN_SPACES(win(), -1); // Resetta bene le dimensioni font if (!_aborted)
if (!print_band(page, *rct)) {
{ for (const RCT* rct = xvt_print_get_next_band(); rct != NULL; rct = xvt_print_get_next_band())
finished = TRUE; {
break; 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
_aborted = xvt_print_close_page(_printrcd) == 0; 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;
}
} }
} }

View File

@ -85,7 +85,7 @@ public:
{ return _aborted; } { return _aborted; }
// @cmember Inizia la stampa (Ritorna FALSE se viene interrotta) // @cmember Inizia la stampa (Ritorna FALSE se viene interrotta)
bool do_print(); bool do_print(word page_from, word page_to, word copies);
// @cmember Costruttore // @cmember Costruttore
TPrintwin(TTextfile& txt); TPrintwin(TTextfile& txt);

View File

@ -910,16 +910,6 @@ TTextfile ::TTextfile (const char *file, int pagesize, direction preferred,
} }
if (fgets (TEXT_TMP, TEXT_TMP_SIZE, _instr) == NULL) if (fgets (TEXT_TMP, TEXT_TMP_SIZE, _instr) == NULL)
break; break;
// if (TEXT_TMP[strlen(TEXT_TMP)-1] == '\n')
// TEXT_TMP[strlen(TEXT_TMP)-1] = '\0';
// if ((_lines) < (_page_start + _page_size))
// {
// TString *ll = new TString (TEXT_TMP);
// _page.add(ll);
// _page_end++;
// TBI process links
// }
_lines++; _lines++;
} }
} }

View File

@ -59,7 +59,7 @@ class TTextfile: public TObject
// @cmember:(INTERNAL) Fine della pagina in coordinate testo // @cmember:(INTERNAL) Fine della pagina in coordinate testo
long _page_end; long _page_end;
// @cmember:(INTERNAL) Numero di righe di <p _page> // @cmember:(INTERNAL) Numero di righe di <p _page>
long _page_size; word _page_size;
// @cmember:(INTERNAL) Numero totale delle linee di testo // @cmember:(INTERNAL) Numero totale delle linee di testo
long _lines; long _lines;
// @cmember:(INTERNAL) Numero della linea corrente // @cmember:(INTERNAL) Numero della linea corrente
@ -123,8 +123,8 @@ public:
// @cmember Ritorna se sono state effettuate delle modifiche // @cmember Ritorna se sono state effettuate delle modifiche
bool changed() const bool changed() const
{ return _dirty; } { return _dirty; }
// @cmember Ritorna il numero di righe per pagina
word page_size() const { return _page_size; }
// @cmember Ritorna la stringa di caratteri senza formattazione // @cmember Ritorna la stringa di caratteri senza formattazione
const char* line(long row, long column = 0, int howmuch = -1); const char* line(long row, long column = 0, int howmuch = -1);