Aggiunta possibilita' di stampa copie multiple e opzione per rifare la

stampa dopo un 'link' da viswin


git-svn-id: svn://10.65.10.50/trunk@107 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1994-08-31 07:29:38 +00:00
parent da21d18988
commit 1ba40c21b0
8 changed files with 886 additions and 874 deletions

View File

@ -4,15 +4,16 @@
#define MSK_1_FILENAME 102 #define MSK_1_FILENAME 102
#define MSK_1_PRINTERS 103 #define MSK_1_PRINTERS 103
#define MSK_1_CODES 111 #define MSK_1_CODES 111
// IMPORTANTE! lasciare il numero 111, // IMPORTANTE! lasciare il numero 111,
// in modo che la maschera sia compatibile // in modo che la maschera sia compatibile
// con i metodi di ba2300, usati anche // con i metodi di ba2300, usati anche
// da printer // da printer
#define MSK_1_SAVE 112 #define MSK_1_SAVE 112
#define MSK_1_SETUP 333 #define MSK_1_SETUP 333
#define MSK_1_ISGRAPHICS 334 #define MSK_1_ISGRAPHICS 334
#define MSK_1_SIZE 335 #define MSK_1_SIZE 335
#define MSK_1_LINES 336 #define MSK_1_LINES 336
#define MSK_1_NPAGES 337
#define MSK_1_PRINTERFILE prn.epf #define MSK_1_PRINTERFILE prn.epf
#define MSK_1_NAMESFILE nms.epf #define MSK_1_NAMESFILE nms.epf

View File

@ -88,6 +88,11 @@ BEGIN
HELP "Selezionare il numero di linee per pollice" HELP "Selezionare il numero di linee per pollice"
END END
NUMBER MSK_1_NPAGES 3 0
BEGIN
PROMPT 57 7 "N.o copie "
END
BUTTON DLG_OK 9 2 BUTTON DLG_OK 9 2
BEGIN BEGIN

View File

@ -401,7 +401,8 @@ break;
const int col = cid - FIRST_FIELD; const int col = cid - FIRST_FIELD;
TMask_field* f = field(cid); TMask_field* f = field(cid);
src = row(rec).get(col); // Set value for cell src = row(rec).get(col); // Set value for cell
if (src && *src && (f->class_id()==CLASS_REAL_FIELD || f->class_id()==CLASS_DATE_FIELD)) if (src && *src && (f->class_id() == CLASS_REAL_FIELD
|| f->class_id() == CLASS_DATE_FIELD))
{ {
src = f->picture_data(src, FALSE); // Get formatted string src = f->picture_data(src, FALSE); // Get formatted string
} }

View File

@ -1,4 +1,4 @@
// $Id: printapp.cpp,v 1.4 1994-08-29 11:04:37 alex Exp $ // $Id: printapp.cpp,v 1.5 1994-08-31 07:29:29 villa Exp $
#include <ctype.h> #include <ctype.h>
#include <stdarg.h> #include <stdarg.h>
@ -784,18 +784,27 @@ set_translation (int lognum, const char *field,
_transtab.add (new _Transfield (lognum, field, from, to)); _transtab.add (new _Transfield (lognum, field, from, to));
} }
void TPrint_application :: void TPrint_application::print ()
print ()
{ {
// open printer if needed // open printer if needed
if (!(printer ().isopen ())) if (!(printer ().isopen ()))
if (!printer ().open ()) if (!printer ().open ())
return; return;
// never print multiple copies if printer is viswin
// only application may repeat printing by setting _repeat_print
int nc = printer().printtype() == screenvis ? 1 : _ncopies;
// NULL cursor passed only prints once // NULL cursor passed only prints once
// pre and post process do everything // pre and post process do everything
if (_cur == NULL) if (_cur == NULL)
{ {
//************************************************
while (_repeat_print || nc--)
{
_repeat_print = FALSE;
int cnt = 0; int cnt = 0;
bool ok = TRUE; bool ok = TRUE;
do do
@ -815,10 +824,15 @@ print ()
} }
} }
while (ok && postprocess_print (0, cnt++) == REPEAT_PAGE); while (ok && postprocess_print (0, cnt++) == REPEAT_PAGE);
// *****************************************************
}
} }
else else
{ {
// cursor exists // cursor exists *********************************************
while (_repeat_print || nc--)
{
_repeat_print = FALSE;
(*_cur) = 0l; (*_cur) = 0l;
_cur->freeze (TRUE); _cur->freeze (TRUE);
@ -836,6 +850,8 @@ print ()
_prind = NULL; _prind = NULL;
} }
} }
// ************************************************************************
}
if (printer().isopen ()) if (printer().isopen ())
{ {
printer().close (); printer().close ();
@ -893,8 +909,7 @@ print_tree (link_item * head)
return go; return go;
} }
bool TPrint_application :: bool TPrint_application::print_one (int file)
print_one (int file)
{ {
int i = 0; int i = 0;
@ -1257,6 +1272,8 @@ TPrint_application::TPrint_application ():TApplication (), _transtab (10),
_footer (10), _rows (100) _footer (10), _rows (100)
{ {
_cur = NULL; _cur = NULL;
_repeat_print = FALSE;
_ncopies = 1;
_currow = _maxrow = 0; _currow = _maxrow = 0;
_auto_ff = FALSE; _auto_ff = FALSE;
_wbar = _wcancel = TRUE; _wbar = _wcancel = TRUE;

View File

@ -76,6 +76,8 @@ class TPrint_application : public TApplication
TProgind* _prind; TProgind* _prind;
const char* _picture; const char* _picture;
MENU_TAG _last_choice; MENU_TAG _last_choice;
int _ncopies;
bool _repeat_print;
// set the printer // set the printer
void set_printer() { printer().set(); } void set_printer() { printer().set(); }
@ -332,8 +334,6 @@ public:
const char* from, const char* to); const char* from, const char* to);
// -------------------------------------------------------- // --------------------------------------------------------
// hypertext interface for viswin // hypertext interface for viswin
// -------------------------------------------------------- // --------------------------------------------------------
@ -457,6 +457,11 @@ public:
void set_page_number(word n) void set_page_number(word n)
{ printer().setcurrentpage(n); } { printer().setcurrentpage(n); }
void set_n_copies(int n) { _ncopies = n; }
int get_n_copies() { return _ncopies; }
void repeat_print() { _repeat_print = TRUE; }
TPrint_application(); TPrint_application();
virtual ~TPrint_application(); virtual ~TPrint_application();
}; };

View File

@ -14,7 +14,7 @@
#include <mask.h> #include <mask.h>
#include <utility.h> #include <utility.h>
#include <viswin.h> #include <viswin.h>
#include <applicat.h> #include <printapp.h>
#include <extcdecl.h> #include <extcdecl.h>
#include <printer.h> #include <printer.h>
@ -298,8 +298,7 @@ bool printers_on_key (TMask_field & f, KEY key);
// fv support structs for config // fv support structs for config
bool PrinterDef :: bool PrinterDef::read (const char *name, FILE * fd)
read (const char *name, FILE * fd)
{ {
_printername = name; _printername = name;
_printername.trim (); _printername.trim ();
@ -380,10 +379,9 @@ read (const char *name, FILE * fd)
return TRUE; return TRUE;
} }
bool PrinterDef :: bool PrinterDef::isdefault ()
isdefault ()
{ {
return strcmp (_printername, "Default") == 0; return strcmp(_printername, "Default") == 0;
} }
////////// TPRINTROW ////////// ////////// TPRINTROW //////////
@ -407,15 +405,12 @@ TPrintrow ::TPrintrow (const TPrintrow & pr)
_lastpos = pr._lastpos; _lastpos = pr._lastpos;
} }
TObject *TPrintrow :: TObject *TPrintrow::dup () const
dup ()
const
{ {
return new TPrintrow (*this); return new TPrintrow (*this);
} }
const char *TPrintrow ::class_name () const char *TPrintrow ::class_name () const
const
{ {
return "Printrow"; return "Printrow";
} }
@ -441,8 +436,7 @@ reset ()
return *this; return *this;
} }
const char *TPrintrow :: const char *TPrintrow::row_codified ()
row_codified ()
{ {
// returns the row with @-codes for font style and color // returns the row with @-codes for font style and color
char last_attr = -1; char last_attr = -1;
@ -488,7 +482,7 @@ row_codified ()
return __tmp_string; return __tmp_string;
} }
TPrintrow & TPrintrow ::put (const char *str, int position, int len) TPrintrow & TPrintrow::put(const char *str, int position, int len)
{ {
if (len < 1) if (len < 1)
len = strlen (str); len = strlen (str);
@ -609,8 +603,7 @@ TPrintrow & TPrintrow ::put (const char *str, int position, int len)
////////// TPRINTER ////////// ////////// TPRINTER //////////
bool bool printers_on_key (TMask_field & f, KEY key)
printers_on_key (TMask_field & f, KEY key)
{ {
if (key == K_SPACE) if (key == K_SPACE)
{ {
@ -632,8 +625,7 @@ printers_on_key (TMask_field & f, KEY key)
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
bool bool set_windows_print_device (TMask_field & f, KEY key)
set_windows_print_device (TMask_field & f, KEY key)
{ {
static char szDevice[80]; static char szDevice[80];
if (key == K_SPACE) if (key == K_SPACE)
@ -834,29 +826,25 @@ setfooterline (int linetoset, TPrintrow * line)
// if (linetoset >= _footersize) _footersize = linetoset+1; // if (linetoset >= _footersize) _footersize = linetoset+1;
} }
void TPrinter :: void TPrinter::setfooterline (int linetoset, const TPrintrow & line)
setfooterline (int linetoset, const TPrintrow & line)
{ {
TPrintrow *p = new TPrintrow (line); TPrintrow *p = new TPrintrow (line);
setfooterline (linetoset, p); setfooterline (linetoset, p);
} }
void TPrinter :: void TPrinter::resetheader ()
resetheader ()
{ {
_header.destroy (); _header.destroy ();
_headersize = 0; _headersize = 0;
} }
void TPrinter :: void TPrinter::resetfooter ()
resetfooter ()
{ {
_footer.destroy (); _footer.destroy ();
// _footersize = 0; // _footersize = 0;
} }
bool TPrinter :: bool TPrinter::printrow (TPrintrow * rowtoprint)
printrow (TPrintrow * rowtoprint)
{ {
if (!isopen ()) if (!isopen ())
return FALSE; return FALSE;
@ -931,9 +919,7 @@ printrow (TPrintrow * rowtoprint)
return TRUE; return TRUE;
} }
word TPrinter :: word TPrinter::rows_left () const
rows_left ()
const
{ {
word left = _formlen - _currentrow - _footersize + 1; word left = _formlen - _currentrow - _footersize + 1;
if (_currentrow < 2) if (_currentrow < 2)
@ -961,8 +947,7 @@ bool TPrinter ::print (TPrintrow & rowtoprint)
return ok; return ok;
} }
bool TPrinter :: bool TPrinter::printheader ()
printheader ()
{ {
if (_headerhandler) if (_headerhandler)
_headerhandler (*this); _headerhandler (*this);
@ -975,8 +960,7 @@ printheader ()
return ok; return ok;
} }
bool TPrinter :: bool TPrinter::printfooter ()
printfooter ()
{ {
if (_footerhandler) if (_footerhandler)
_footerhandler (*this); _footerhandler (*this);
@ -996,8 +980,7 @@ printfooter ()
return ok; return ok;
} }
bool TPrinter :: bool TPrinter::skip (int linestoskip)
skip (int linestoskip)
{ {
int jumpline; int jumpline;
@ -1006,8 +989,7 @@ skip (int linestoskip)
return jump (jumpline); return jump (jumpline);
} }
bool TPrinter :: bool TPrinter::jump (int jumpline)
jump (int jumpline)
{ {
int i = 0; int i = 0;
bool ok = TRUE; bool ok = TRUE;
@ -1024,8 +1006,7 @@ jump (int jumpline)
return ok; return ok;
} }
bool TPrinter :: bool TPrinter::formfeed ()
formfeed ()
{ {
const int lastrow = _formlen - _footersize; const int lastrow = _formlen - _footersize;
for (; _currentrow <= lastrow; _currentrow++) for (; _currentrow <= lastrow; _currentrow++)
@ -1033,8 +1014,7 @@ formfeed ()
return printfooter (); return printfooter ();
} }
void TPrinter :: void TPrinter::reset ()
reset ()
{ {
resetheader (); resetheader ();
resetfooter (); resetfooter ();
@ -1042,8 +1022,7 @@ reset ()
_currentrow = 1; _currentrow = 1;
} }
bool TPrinter :: bool TPrinter::printformfeed ()
printformfeed ()
{ {
#if XVT_OS != XVT_OS_WIN #if XVT_OS != XVT_OS_WIN
const PrinterDef & pd = get_description (_curprn); const PrinterDef & pd = get_description (_curprn);
@ -1054,8 +1033,7 @@ printformfeed ()
return TRUE; return TRUE;
} }
bool TPrinter :: bool TPrinter::open ()
open ()
{ {
// qui // qui
#if XVT_OS==XVT_OS_SCOUNIX #if XVT_OS==XVT_OS_SCOUNIX
@ -1139,10 +1117,9 @@ open ()
return _isopen = TRUE; return _isopen = TRUE;
} }
void TPrinter :: void TPrinter::set()
set ()
{ {
TMask mask ("bagn001a.msk"); TMask mask ("bagn001a");
TToken_string pn1 (50), pn2 (100); TToken_string pn1 (50), pn2 (100);
int i; int i;
@ -1176,6 +1153,7 @@ set ()
mask.set (MSK_1_PRINTERS, format ("%d", _curprn)); mask.set (MSK_1_PRINTERS, format ("%d", _curprn));
mask.set (MSK_1_CODES, format ("%d", _curcode)); mask.set (MSK_1_CODES, format ("%d", _curcode));
mask.set (MSK_1_FILENAME, _printerfile); mask.set (MSK_1_FILENAME, _printerfile);
mask.set (MSK_1_NPAGES, format("%d",((TPrint_application*)MainApp())->get_n_copies()));
mask.reset (MSK_1_SAVE); mask.reset (MSK_1_SAVE);
if (mask.run () == K_ESC) if (mask.run () == K_ESC)
@ -1194,6 +1172,7 @@ set ()
// get user choices // get user choices
_curprn = atoi (mask.get (MSK_1_PRINTERS)); _curprn = atoi (mask.get (MSK_1_PRINTERS));
((TPrint_application*)MainApp())->set_n_copies(atoi (mask.get (MSK_1_NPAGES)));
PrinterDef & def = (PrinterDef &) get_description (_curprn); PrinterDef & def = (PrinterDef &) get_description (_curprn);
switch (atoi (mask.get (MSK_1_TYPE))) switch (atoi (mask.get (MSK_1_TYPE)))
{ {
@ -1263,6 +1242,7 @@ set ()
mask.set (MSK_1_ISGRAPHICS, _isgraphics ? "X" : ""); mask.set (MSK_1_ISGRAPHICS, _isgraphics ? "X" : "");
mask.set (MSK_1_SIZE, format ("%d", _ch_size)); mask.set (MSK_1_SIZE, format ("%d", _ch_size));
mask.set (MSK_1_LINES, format ("%d", _lines_per_inch)); mask.set (MSK_1_LINES, format ("%d", _lines_per_inch));
mask.set (MSK_1_NPAGES, format("%d",((TPrint_application*)MainApp())->get_n_copies()));
if (_printertype == fileprinter) if (_printertype == fileprinter)
mask.set (MSK_1_TYPE, "1"); mask.set (MSK_1_TYPE, "1");
@ -1319,7 +1299,7 @@ set ()
mask.set_workfile (s); mask.set_workfile (s);
mask.save (); mask.save ();
} }
((TPrint_application*)MainApp())->set_n_copies(atoi (mask.get (MSK_1_NPAGES)));
switch (atoi (mask.get (MSK_1_TYPE))) switch (atoi (mask.get (MSK_1_TYPE)))
{ {
case 0: // stampante case 0: // stampante
@ -1349,8 +1329,7 @@ set ()
MainApp ()->enable_menu_item (M_FILE_PG_SETUP); MainApp ()->enable_menu_item (M_FILE_PG_SETUP);
} }
void TPrinter :: void TPrinter::close ()
close ()
{ {
if (isopen () && _currentrow > 1 && if (isopen () && _currentrow > 1 &&
(_footersize || (_printertype != screenvis && _printertype != winprinter))) (_footersize || (_printertype != screenvis && _printertype != winprinter)))
@ -1434,8 +1413,7 @@ TFile_printer ::TFile_printer (const char *ffile, const char *label, int len_rec
} }
void TFile_printer :: void TFile_printer::open()
open ()
{ {
} }

View File

@ -7,7 +7,8 @@
#include <config.h> #include <config.h>
#include <execp.h> #include <execp.h>
#include <urldefid.h> #include <urldefid.h>
#include <applicat.h> #include <printapp.h>
#include <mailbox.h>
#ifndef __PRINTER_H #ifndef __PRINTER_H
typedef void (*LINKHANDLER) (int, const char *); typedef void (*LINKHANDLER) (int, const char *);
@ -58,6 +59,46 @@ extern "C"
const long E_ADDLINE = 488l; const long E_ADDLINE = 488l;
const long E_ADDLINE_ONSCREEN = 467l; const long E_ADDLINE_ONSCREEN = 467l;
void TViswin::exec_link()
{
if (_linkID != -1)
{
LINKHANDLER pl = MainApp ()->printer ().getlinkhandler ();
if (pl)
(*pl) (_linkID, _multiple ? (const char *) _multiple_link :
_linktxt);
// dai opzione per rifare la stampa se e' arrivato un messaggio
// dall'applicazione chiamata
// schiaffa indi il tutto in una funzione
TMailbox m;
if (m.next_s(MSG_LN) != NULL)
{
if (yesno_box("Si desidera riaggiornare la stampa?"))
{
((TPrint_application*)MainApp())->repeat_print();
#if XVT_OS == XVT_OS_WIN
xvt_statbar_set ("");
xvt_statbar_refresh ();
#endif
stop_run(K_ENTER);
}
}
set_focus();
check_link();
_need_update = TRUE;
force_update();
do_events();
check_link (&_point);
}
else
beep();
}
void TViswin::display_link (long y, long x1, long x2, const char *d) void TViswin::display_link (long y, long x1, long x2, const char *d)
{ {
if (!_link_displayed) if (!_link_displayed)
@ -72,6 +113,7 @@ void TViswin::display_link (long y, long x1, long x2, const char *d)
} }
} }
void TViswin::erase_link (long y, long x1, long x2) void TViswin::erase_link (long y, long x1, long x2)
{ {
if (_link_displayed) if (_link_displayed)
@ -209,7 +251,7 @@ bool TViswin::in_text (const TPoint & p) const
} }
bool TViswin ::need_paint_sel (bool smart) bool TViswin::need_paint_sel (bool smart)
{ {
TPoint p1, p2; TPoint p1, p2;
adjust_selection (p1, p2); adjust_selection (p1, p2);
@ -880,21 +922,7 @@ void TViswin::handler (WINDOW win, EVENT * ep)
check_link (&_point); check_link (&_point);
break; break;
case DLG_LINK: case DLG_LINK:
if (_linkID != -1) exec_link();
{
LINKHANDLER pl = MainApp ()->printer ().getlinkhandler ();
if (pl)
(*pl) (_linkID, _multiple ? (const char *) _multiple_link :
_linktxt);
set_focus ();
check_link ();
_need_update = TRUE;
force_update ();
do_events ();
check_link (&_point);
}
else
beep ();
break; break;
} }
break; break;
@ -1356,8 +1384,7 @@ void TViswin::handler (WINDOW win, EVENT * ep)
update (); update ();
} }
bool TViswin :: bool TViswin::on_key (KEY key)
on_key (KEY key)
{ {
EVENT_TYPE type = E_USER; EVENT_TYPE type = E_USER;
@ -1388,21 +1415,7 @@ on_key (KEY key)
} }
break; break;
case CTRL_C: case CTRL_C:
if (_linkID != -1) exec_link();
{
LINKHANDLER pl = MainApp ()->printer ().getlinkhandler ();
if (pl)
(*pl) (_linkID, _multiple ? (const char *) _multiple_link :
_linktxt);
set_focus ();
check_link ();
_need_update = TRUE;
force_update ();
do_events ();
check_link (&_point);
}
else
beep ();
break; break;
case CTRL_S: case CTRL_S:
if (_isprint) if (_isprint)
@ -1451,17 +1464,7 @@ on_key (KEY key)
case K_CTRL_ENTER: case K_CTRL_ENTER:
if (_linkID != -1) if (_linkID != -1)
{ {
LINKHANDLER pl = MainApp ()->printer ().getlinkhandler (); exec_link();
if (pl)
(*pl) (_linkID, _multiple ? (const char *) _multiple_link :
_linktxt);
_need_update = TRUE;
set_focus ();
check_link ();
_need_update = TRUE;
force_update ();
do_events ();
check_link (&_point);
} }
else else
dispatch_e_char (_button[_curbut], K_SPACE); dispatch_e_char (_button[_curbut], K_SPACE);

View File

@ -111,6 +111,8 @@ protected:
void erase_link(long, long, long); void erase_link(long, long, long);
void display_link(long, long, long, const char*); void display_link(long, long, long, const char*);
void freeze() { _frozen = TRUE; } void freeze() { _frozen = TRUE; }
void exec_link();
protected: protected:
virtual void update(); virtual void update();