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

@ -13,6 +13,7 @@
#define MSK_1_ISGRAPHICS 334
#define MSK_1_SIZE 335
#define MSK_1_LINES 336
#define MSK_1_NPAGES 337
#define MSK_1_PRINTERFILE prn.epf
#define MSK_1_NAMESFILE nms.epf

View File

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

View File

@ -401,7 +401,8 @@ break;
const int col = cid - FIRST_FIELD;
TMask_field* f = field(cid);
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
}

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 <stdarg.h>
@ -784,18 +784,27 @@ set_translation (int lognum, const char *field,
_transtab.add (new _Transfield (lognum, field, from, to));
}
void TPrint_application ::
print ()
void TPrint_application::print ()
{
// open printer if needed
if (!(printer ().isopen ()))
if (!printer ().open ())
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
// pre and post process do everything
if (_cur == NULL)
{
//************************************************
while (_repeat_print || nc--)
{
_repeat_print = FALSE;
int cnt = 0;
bool ok = TRUE;
do
@ -815,10 +824,15 @@ print ()
}
}
while (ok && postprocess_print (0, cnt++) == REPEAT_PAGE);
// *****************************************************
}
}
else
{
// cursor exists
// cursor exists *********************************************
while (_repeat_print || nc--)
{
_repeat_print = FALSE;
(*_cur) = 0l;
_cur->freeze (TRUE);
@ -836,6 +850,8 @@ print ()
_prind = NULL;
}
}
// ************************************************************************
}
if (printer().isopen ())
{
printer().close ();
@ -893,8 +909,7 @@ print_tree (link_item * head)
return go;
}
bool TPrint_application ::
print_one (int file)
bool TPrint_application::print_one (int file)
{
int i = 0;
@ -1257,6 +1272,8 @@ TPrint_application::TPrint_application ():TApplication (), _transtab (10),
_footer (10), _rows (100)
{
_cur = NULL;
_repeat_print = FALSE;
_ncopies = 1;
_currow = _maxrow = 0;
_auto_ff = FALSE;
_wbar = _wcancel = TRUE;

View File

@ -76,6 +76,8 @@ class TPrint_application : public TApplication
TProgind* _prind;
const char* _picture;
MENU_TAG _last_choice;
int _ncopies;
bool _repeat_print;
// set the printer
void set_printer() { printer().set(); }
@ -332,8 +334,6 @@ public:
const char* from, const char* to);
// --------------------------------------------------------
// hypertext interface for viswin
// --------------------------------------------------------
@ -457,6 +457,11 @@ public:
void set_page_number(word 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();
virtual ~TPrint_application();
};

View File

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

View File

@ -7,7 +7,8 @@
#include <config.h>
#include <execp.h>
#include <urldefid.h>
#include <applicat.h>
#include <printapp.h>
#include <mailbox.h>
#ifndef __PRINTER_H
typedef void (*LINKHANDLER) (int, const char *);
@ -58,6 +59,46 @@ extern "C"
const long E_ADDLINE = 488l;
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)
{
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)
{
if (_link_displayed)
@ -880,21 +922,7 @@ void TViswin::handler (WINDOW win, EVENT * ep)
check_link (&_point);
break;
case DLG_LINK:
if (_linkID != -1)
{
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 ();
exec_link();
break;
}
break;
@ -1356,8 +1384,7 @@ void TViswin::handler (WINDOW win, EVENT * ep)
update ();
}
bool TViswin ::
on_key (KEY key)
bool TViswin::on_key (KEY key)
{
EVENT_TYPE type = E_USER;
@ -1388,21 +1415,7 @@ on_key (KEY key)
}
break;
case CTRL_C:
if (_linkID != -1)
{
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 ();
exec_link();
break;
case CTRL_S:
if (_isprint)
@ -1451,17 +1464,7 @@ on_key (KEY key)
case K_CTRL_ENTER:
if (_linkID != -1)
{
LINKHANDLER pl = MainApp ()->printer ().getlinkhandler ();
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);
exec_link();
}
else
dispatch_e_char (_button[_curbut], K_SPACE);

View File

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