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

@ -1,20 +1,21 @@
// Header file for PRINT SETUP mask // Header file for PRINT SETUP mask
#define MSK_1_TYPE 101 #define MSK_1_TYPE 101
#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_NAMESFILE nms.epf #define MSK_1_PRINTERFILE prn.epf
#define PRINTERSFILE "prn.epf" #define MSK_1_NAMESFILE nms.epf
#define NAMESFILE "nms.epf" #define PRINTERSFILE "prn.epf"
#define NAMESFILE "nms.epf"

View File

@ -1,104 +1,109 @@
#include <bagn001a.h> #include <bagn001a.h>
PAGE "IMPOSTAZIONE STAMPANTE" -1 -1 76 10 PAGE "IMPOSTAZIONE STAMPANTE" -1 -1 76 10
RADIOBUTTON MSK_1_TYPE 16 RADIOBUTTON MSK_1_TYPE 16
BEGIN BEGIN
PROMPT 1 1 "Stampa su..." PROMPT 1 1 "Stampa su..."
HELP "Selezionare il tipo di stampa" HELP "Selezionare il tipo di stampa"
ITEM "0|Stampante" ITEM "0|Stampante"
MESSAGE DISABLE,MSK_1_FILENAME|RESET,MSK_1_FILENAME MESSAGE DISABLE,MSK_1_FILENAME|RESET,MSK_1_FILENAME
MESSAGE ENABLE,MSK_1_PRINTERS MESSAGE ENABLE,MSK_1_PRINTERS
MESSAGE ENABLE,MSK_1_CODES MESSAGE ENABLE,MSK_1_CODES
MESSAGE ENABLE,MSK_1_SIZE MESSAGE ENABLE,MSK_1_SIZE
ITEM "1|File" ITEM "1|File"
MESSAGE ENABLE,MSK_1_FILENAME|DISABLE,MSK_1_PRINTERS MESSAGE ENABLE,MSK_1_FILENAME|DISABLE,MSK_1_PRINTERS
MESSAGE ENABLE,MSK_1_CODES MESSAGE ENABLE,MSK_1_CODES
MESSAGE DISABLE,MSK_1_SIZE MESSAGE DISABLE,MSK_1_SIZE
ITEM "2|Video" ITEM "2|Video"
MESSAGE DISABLE,MSK_1_FILENAME|RESET,MSK_1_FILENAME MESSAGE DISABLE,MSK_1_FILENAME|RESET,MSK_1_FILENAME
MESSAGE DISABLE,MSK_1_PRINTERS MESSAGE DISABLE,MSK_1_PRINTERS
MESSAGE DISABLE,MSK_1_CODES MESSAGE DISABLE,MSK_1_CODES
MESSAGE DISABLE,MSK_1_SIZE MESSAGE DISABLE,MSK_1_SIZE
END END
LIST MSK_1_PRINTERS 40 LIST MSK_1_PRINTERS 40
BEGIN BEGIN
/* viene riempito runtime con nomi letti da config */ /* viene riempito runtime con nomi letti da config */
PROMPT 21 1 "Stampante " PROMPT 21 1 "Stampante "
HELP "Selezionare la stampante desiderata" HELP "Selezionare la stampante desiderata"
END END
STRING MSK_1_FILENAME 40 STRING MSK_1_FILENAME 40
BEGIN BEGIN
PROMPT 21 3 "Nome file " PROMPT 21 3 "Nome file "
HELP "Inserire qui il nome del file in caso di stampa su file" HELP "Inserire qui il nome del file in caso di stampa su file"
END END
LIST MSK_1_CODES 40 LIST MSK_1_CODES 40
BEGIN BEGIN
PROMPT 21 5 "Tipo stampa " PROMPT 21 5 "Tipo stampa "
/* pure */ /* pure */
HELP "Selezionare la modalita' nelle quale si desidera la stampa" HELP "Selezionare la modalita' nelle quale si desidera la stampa"
END END
BUTTON MSK_1_SETUP 20 1 BUTTON MSK_1_SETUP 20 1
BEGIN BEGIN
PROMPT 33 5 "Imposta stampante... " PROMPT 33 5 "Imposta stampante... "
HELP "Chiama l'Impostazione Stampante di Windows" HELP "Chiama l'Impostazione Stampante di Windows"
MESSAGE EXIT,MSK_1_SETUP MESSAGE EXIT,MSK_1_SETUP
END END
BOOLEAN MSK_1_SAVE BOOLEAN MSK_1_SAVE
BEGIN BEGIN
PROMPT 1 6 "Salva la configurazione" PROMPT 1 6 "Salva la configurazione"
HELP "Salva la configurazione corrente della stampante" HELP "Salva la configurazione corrente della stampante"
END END
BOOLEAN MSK_1_ISGRAPHICS BOOLEAN MSK_1_ISGRAPHICS
BEGIN BEGIN
PROMPT 1 7 "Stampa elementi grafici" PROMPT 1 7 "Stampa elementi grafici"
HELP "Stampa elementi grafici (linee, box, logo) se la stampante lo consente" HELP "Stampa elementi grafici (linee, box, logo) se la stampante lo consente"
END END
LIST MSK_1_SIZE 3 LIST MSK_1_SIZE 3
BEGIN BEGIN
PROMPT 57 5 "Carattere " PROMPT 57 5 "Carattere "
ITEM "7|7" ITEM "7|7"
ITEM "8|8" ITEM "8|8"
ITEM "10|10" ITEM "10|10"
ITEM "12|12" ITEM "12|12"
ITEM "15|15" ITEM "15|15"
ITEM "17|17" ITEM "17|17"
HELP "Selezionare le dimensioni del carattere di stampa" HELP "Selezionare le dimensioni del carattere di stampa"
END END
LIST MSK_1_LINES 3 LIST MSK_1_LINES 3
BEGIN BEGIN
PROMPT 57 6 "Linee/Inch " PROMPT 57 6 "Linee/Inch "
ITEM "4|4" ITEM "4|4"
ITEM "5|5" ITEM "5|5"
ITEM "6|6" ITEM "6|6"
ITEM "7|7" ITEM "7|7"
ITEM "8|8" ITEM "8|8"
ITEM "9|9" ITEM "9|9"
ITEM "10|10" ITEM "10|10"
HELP "Selezionare il numero di linee per pollice" HELP "Selezionare il numero di linee per pollice"
END END
NUMBER MSK_1_NPAGES 3 0
BUTTON DLG_OK 9 2 BEGIN
BEGIN PROMPT 57 7 "N.o copie "
PROMPT -12 -1 "" END
END
BUTTON DLG_CANCEL 9 2 BUTTON DLG_OK 9 2
BEGIN BEGIN
PROMPT -22 -1 "" PROMPT -12 -1 ""
END END
ENDPAGE BUTTON DLG_CANCEL 9 2
BEGIN
ENDMASK PROMPT -22 -1 ""
END
ENDPAGE
ENDMASK

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,57 +784,73 @@ 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)
{ {
int cnt = 0; //************************************************
bool ok = TRUE; while (_repeat_print || nc--)
do {
{ _repeat_print = FALSE;
if (preprocess_print (0, cnt))
int cnt = 0;
bool ok = TRUE;
do
{ {
int cnt2 = 0; if (preprocess_print (0, cnt))
do {
{ int cnt2 = 0;
if (preprocess_page (0, cnt2)) do
{ {
set_page (0, cnt2); if (preprocess_page (0, cnt2))
ok = print_one (0); {
} set_page (0, cnt2);
} ok = print_one (0);
while (ok && postprocess_page (0, cnt2++) == REPEAT_PAGE); }
} }
} while (ok && postprocess_page (0, cnt2++) == REPEAT_PAGE);
while (ok && postprocess_print (0, cnt++) == REPEAT_PAGE); }
}
while (ok && postprocess_print (0, cnt++) == REPEAT_PAGE);
// *****************************************************
}
} }
else else
{ {
// cursor exists // cursor exists *********************************************
(*_cur) = 0l; while (_repeat_print || nc--)
_cur->freeze (TRUE); {
_repeat_print = FALSE;
(*_cur) = 0l;
_cur->freeze (TRUE);
if (_cur->items () >= _wthr && if (_cur->items () >= _wthr &&
(_force_progind || printer ().printtype () != screenvis)) (_force_progind || printer ().printtype () != screenvis))
_prind = new TProgind (_cur->items (), _prind = new TProgind (_cur->items (),
(char *) (const char *) _wmess, (char *) (const char *) _wmess,
_wcancel, _wbar, 35); _wcancel, _wbar, 35);
print_tree (_pr_tree); print_tree (_pr_tree);
_cur->freeze (FALSE); _cur->freeze (FALSE);
if (_prind) if (_prind)
{ {
delete _prind;; delete _prind;;
_prind = NULL; _prind = NULL;
} }
}
// ************************************************************************
} }
if (printer().isopen ()) if (printer().isopen ())
{ {
@ -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;
@ -1256,7 +1271,9 @@ TPrint_application::TPrint_application ():TApplication (), _transtab (10),
_cursors (10), _header (10), _cursors (10), _header (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

@ -1,468 +1,473 @@
// trattasi di -*-c++-*- // trattasi di -*-c++-*-
#ifndef __PRINTAPP_H #ifndef __PRINTAPP_H
#define __PRINTAPP_H #define __PRINTAPP_H
#ifndef __APPLICATION_H #ifndef __APPLICATION_H
#include <applicat.h> #include <applicat.h>
#endif #endif
#ifndef __PRINTER_H #ifndef __PRINTER_H
#include <printer.h> #include <printer.h>
#endif #endif
#ifndef __RELATION_H #ifndef __RELATION_H
#include <relation.h> #include <relation.h>
#endif #endif
#ifndef __STRINGS_H #ifndef __STRINGS_H
#include <strings.h> #include <strings.h>
#endif #endif
// compatibility // compatibility
#define TPrintapp TPrint_application #define TPrintapp TPrint_application
enum print_action { REPEAT_PAGE, NEXT_PAGE }; enum print_action { REPEAT_PAGE, NEXT_PAGE };
// user functions to pass field informations to setrow() // user functions to pass field informations to setrow()
// no class or nice C++ interface since varargs is nasty // no class or nice C++ interface since varargs is nasty
// FLD(Num.logico, Nome campo [, da [, a]]) // FLD(Num.logico, Nome campo [, da [, a]])
const char* FLD(int lognum, const char* f, int from = -1, int to = -1); const char* FLD(int lognum, const char* f, int from = -1, int to = -1);
// FLD(Num. logico, Nome campo numerico, Picture string) // FLD(Num. logico, Nome campo numerico, Picture string)
const char* FLD(int lognum, const char* f, const char* picture); const char* FLD(int lognum, const char* f, const char* picture);
// FLD(Nome tabella, Nome campo numerico, Picture string) // FLD(Nome tabella, Nome campo numerico, Picture string)
const char* FLD(const char* tabname, const char* f, const char* picture); const char* FLD(const char* tabname, const char* f, const char* picture);
// FLD(Num.logico, Nome campo [, da [, a]]) // FLD(Num.logico, Nome campo [, da [, a]])
const char* FLD(const char* tabname, const char* f, int from = -1, int to = -1); const char* FLD(const char* tabname, const char* f, int from = -1, int to = -1);
struct link_item { struct link_item {
int _logicnum; int _logicnum;
link_item* _son; link_item* _son;
link_item* _brother; link_item* _brother;
int _cnt; int _cnt;
link_item(int l) link_item(int l)
{ _logicnum = l; _son = NULL; _brother = NULL; _cnt = 0; } { _logicnum = l; _son = NULL; _brother = NULL; _cnt = 0; }
}; };
class TProgind; class TProgind;
class TPrint_application : public TApplication class TPrint_application : public TApplication
{ {
TArray _rows; // rows descriptor TArray _rows; // rows descriptor
TArray _cursors; // cursor array TArray _cursors; // cursor array
TCursor* _cur; // current cursor TCursor* _cur; // current cursor
TArray _transtab; // field translation table TArray _transtab; // field translation table
TArray _header; // header lines TArray _header; // header lines
TArray _footer; // footer lines TArray _footer; // footer lines
int _currow; // current print row int _currow; // current print row
TPrintstyle _curstyle; // current print style TPrintstyle _curstyle; // current print style
bool _auto_ff; // automatic form feed after each page bool _auto_ff; // automatic form feed after each page
const char* _wmess; // wait message for progind const char* _wmess; // wait message for progind
bool _wbar; // bar y/n for progind bool _wbar; // bar y/n for progind
bool _wcancel; // cancel button enabled bool _wcancel; // cancel button enabled
int _wthr; // minimum # of items to show print progind int _wthr; // minimum # of items to show print progind
const char* _confpr; // config filename for printer const char* _confpr; // config filename for printer
char _fillchar; // fill character for empty fields char _fillchar; // fill character for empty fields
link_item* _pr_tree; // functions for autom. printing of relations link_item* _pr_tree; // functions for autom. printing of relations
int _maxrow; // reference to maxrow int _maxrow; // reference to maxrow
int _cur_file; int _cur_file;
bool _print_defined; bool _print_defined;
bool _force_progind; bool _force_progind;
bool _force_setpage; bool _force_setpage;
bool _print_zero; bool _print_zero;
TProgind* _prind; TProgind* _prind;
const char* _picture; const char* _picture;
MENU_TAG _last_choice; MENU_TAG _last_choice;
int _ncopies;
// set the printer bool _repeat_print;
void set_printer() { printer().set(); }
// print a single record; does not advance cursor // set the printer
// returns failure or success void set_printer() { printer().set(); }
bool print_one(int file); // print a single record; does not advance cursor
// to be documented but very fig // returns failure or success
bool print_tree(link_item* head); bool print_one(int file);
// to be documented but very fig
static void _pp_header(TPrinter& pr); bool print_tree(link_item* head);
static void _pp_footer(TPrinter& pr);
static void _pp_link(int id, const char* s); static void _pp_header(TPrinter& pr);
static void _pp_footer(TPrinter& pr);
link_item* _look_print_node(link_item* head, int logicnum); static void _pp_link(int id, const char* s);
void _reset_tree(link_item* head);
virtual bool create(); link_item* _look_print_node(link_item* head, int logicnum);
virtual bool destroy(); void _reset_tree(link_item* head);
virtual bool create();
virtual bool destroy();
protected:
// **************************************************** protected:
// ISTRUZIONI PER l'USO
// **************************************************** // ****************************************************
// // ISTRUZIONI PER l'USO
// La Printapp, saggiamente, consente di operare su uno // ****************************************************
// o piu' cursori stampando automaticamente anche files //
// collegati. La sequenza delle operazioni e' la seguente: // La Printapp, saggiamente, consente di operare su uno
// // o piu' cursori stampando automaticamente anche files
// 1) Derivare una classe da TPrint_application // collegati. La sequenza delle operazioni e' la seguente:
// 2) Implementare user_create() e user_destroy(); //
// Nella user_create() si creino i // 1) Derivare una classe da TPrint_application
// necessari cursori, e li si dia in pasto a Printapp // 2) Implementare user_create() e user_destroy();
// usando add_cursor(). Si puo' fare add_cursor(new TCursor(...)) // Nella user_create() si creino i
// dato che il cursore viene distrutto automaticamente. // necessari cursori, e li si dia in pasto a Printapp
// 3) Per ciascun file del cursore che si desidera porre // usando add_cursor(). Si puo' fare add_cursor(new TCursor(...))
// nell'albero di stampa, si faccia add_file(logicnum [,from]); // dato che il cursore viene distrutto automaticamente.
// [from] sara' il file a cui e' collegato nella relazione. // 3) Per ciascun file del cursore che si desidera porre
// add_file VA FATTA anche per il file principale, se no // nell'albero di stampa, si faccia add_file(logicnum [,from]);
// non stampera' nulla; // [from] sara' il file a cui e' collegato nella relazione.
// ********************************************************* // add_file VA FATTA anche per il file principale, se no
// FUNZIONI VIRTUALI OBBLIGATORIE // non stampera' nulla;
// ********************************************************* // *********************************************************
// 4) Si definiscono le necessarie funzioni virtuali: e' // FUNZIONI VIRTUALI OBBLIGATORIE
// sicuramente necessaria la set_page(file) nella quale // *********************************************************
// si metteranno (sotto if o switch) le istruzioni // 4) Si definiscono le necessarie funzioni virtuali: e'
// set_row (vedi sotto) corrispondenti alla pagina // sicuramente necessaria la set_page(file) nella quale
// logica relativa a ciascun record di ogni file da stampare. // si metteranno (sotto if o switch) le istruzioni
// Va definita anche set_print() in cui si presentera' ;a // set_row (vedi sotto) corrispondenti alla pagina
// maschera di scelta se necessaria o una box yes_no; // logica relativa a ciascun record di ogni file da stampare.
// Ritornando TRUE da set_print la stampa viene eseguita // Va definita anche set_print() in cui si presentera' ;a
// automaticamente (in genere ritorna FALSE se l'utente // maschera di scelta se necessaria o una box yes_no;
// annulla la stampa con ESC.) // Ritornando TRUE da set_print la stampa viene eseguita
// // automaticamente (in genere ritorna FALSE se l'utente
// Alla set_page, come alle pre_ e post_ process, viene // annulla la stampa con ESC.)
// passato 0 se il cursore attuale e' nullo (vedi sotto). //
// ********************************************************* // Alla set_page, come alle pre_ e post_ process, viene
// FUNZIONI VIRTUALI FACOLTATIVE // passato 0 se il cursore attuale e' nullo (vedi sotto).
// ********************************************************* // *********************************************************
// 5) Le varie funzioni pre_ e post_ process _page e _print // FUNZIONI VIRTUALI FACOLTATIVE
// vengono chiamate prima e dopo la stampa di ogni record // *********************************************************
// o gruppo di record relativo alla relazione immessa; // 5) Le varie funzioni pre_ e post_ process _page e _print
// ad esempio, postprocess_print() viene chiamata per il // vengono chiamate prima e dopo la stampa di ogni record
// file principale una volta dopo l'intera stampa; per // o gruppo di record relativo alla relazione immessa;
// un file collegato nella relazione, e' chiamata tante // ad esempio, postprocess_print() viene chiamata per il
// volte quanti gruppi di almeno un record esistono per // file principale una volta dopo l'intera stampa; per
// record del file genitore. Qui si possono modificare // un file collegato nella relazione, e' chiamata tante
// righe, calcolare totali etc. A queste funzioni // volte quanti gruppi di almeno un record esistono per
// viene sempre passato il file (logicnum) in corso di stampa e // record del file genitore. Qui si possono modificare
// un contatore che indica quante volte la stampa e' stata // righe, calcolare totali etc. A queste funzioni
// ripetuta. le pre_ ritornano TRUE o FALSE, nell'ultimo // viene sempre passato il file (logicnum) in corso di stampa e
// caso interrompono la stampa; le post_ ritornano // un contatore che indica quante volte la stampa e' stata
// NEXT_PAGE (comportamento normale) o REPEAT_PAGE // ripetuta. le pre_ ritornano TRUE o FALSE, nell'ultimo
// (indovina cosa fa). // caso interrompono la stampa; le post_ ritornano
// 6) set_print() viene chiamata dalla voce Selezione, // NEXT_PAGE (comportamento normale) o REPEAT_PAGE
// unica del secondo menu. E' il posto dove mettere // (indovina cosa fa).
// una buona maschera di selezione di cosa stampare. // 6) set_print() viene chiamata dalla voce Selezione,
// Alla fine, si esegua enable_print_menu() per // unica del secondo menu. E' il posto dove mettere
// abilitare la voce Stampa, inizialmente inattiva. // una buona maschera di selezione di cosa stampare.
// 7) cancel_hook() permette di intercettare la // Alla fine, si esegua enable_print_menu() per
// cancellazione della stampa; ritornando TRUE // abilitare la voce Stampa, inizialmente inattiva.
// la stampa viene effettivamente cancellata // 7) cancel_hook() permette di intercettare la
// Tutti i parametri relativi al progress indicator // cancellazione della stampa; ritornando TRUE
// vengono settati da funzioni apposite (vedi oltre) // la stampa viene effettivamente cancellata
// **************************************************** // Tutti i parametri relativi al progress indicator
// Molte altre minchiatine (form feed automatici, header, // vengono settati da funzioni apposite (vedi oltre)
// footer etc) sono spiegate nel seguito // ****************************************************
// **************************************************** // Molte altre minchiatine (form feed automatici, header,
// footer etc) sono spiegate nel seguito
virtual void user_create() {} // ****************************************************
virtual void user_destroy() {}
virtual void user_create() {}
// set print, bound to menu :Selezione:Stampa virtual void user_destroy() {}
// chiamata automaticamente dopo user_create()
virtual bool set_print(int i = 1) { return FALSE; } // set print, bound to menu :Selezione:Stampa
// chiamata automaticamente dopo user_create()
// set_row functions MUST be called here in a switch virtual bool set_print(int i = 1) { return FALSE; }
// for each particular file being printed
virtual void set_page(int file, int cnt) {} // set_row functions MUST be called here in a switch
// for each particular file being printed
// called before processing each page virtual void set_page(int file, int cnt) {}
// used to set print strings from tables or files
// not included in relation // called before processing each page
// returning FALSE cancels page printing // used to set print strings from tables or files
// counter is the current print page number // not included in relation
virtual bool preprocess_page(int file, int counter) // returning FALSE cancels page printing
{ return TRUE; } // counter is the current print page number
virtual bool preprocess_page(int file, int counter)
// same before each print request { return TRUE; }
// e.g. to initialize counters
// returning FALSE cancels print request or subtree // same before each print request
virtual bool preprocess_print(int file, int counter) // e.g. to initialize counters
{ return TRUE; } // returning FALSE cancels print request or subtree
virtual bool preprocess_print(int file, int counter)
// postprocessing; returning REPEAT_PAGE reprints the { return TRUE; }
// whole page (after all sons are printed) or print
// counter is the current page or print number // postprocessing; returning REPEAT_PAGE reprints the
virtual print_action postprocess_page(int file, int counter) // whole page (after all sons are printed) or print
{ return NEXT_PAGE; } // counter is the current page or print number
virtual print_action postprocess_print(int file, int counter) virtual print_action postprocess_page(int file, int counter)
{ return NEXT_PAGE; } { return NEXT_PAGE; }
// executed after all print job is completed virtual print_action postprocess_print(int file, int counter)
virtual void postclose_print() {} { return NEXT_PAGE; }
// executed after all print job is completed
// called when LINK button is pressed with active selection in virtual void postclose_print() {}
// preview window
virtual void process_link(int id, const char* text) {} // called when LINK button is pressed with active selection in
// preview window
virtual void process_link(int id, const char* text) {}
// called when user cancels print; returning TRUE
// actually stops printing; not called if no cancel
virtual bool cancel_hook() {return TRUE;} // called when user cancels print; returning TRUE
// actually stops printing; not called if no cancel
// bound to TApplication print menu virtual bool cancel_hook() {return TRUE;}
// redefined ONLY for very special purposes
virtual void print(); // bound to TApplication print menu
// redefined ONLY for very special purposes
// bound to <select> menu and automatically called after virtual void print();
// user_create()
void do_print(int n); // bound to <select> menu and automatically called after
// user_create()
public: void do_print(int n);
// -------------------------------------------------------------- public:
// COME SETTARE LE RIGHE DI STAMPA
// -------------------------------------------------------------- // --------------------------------------------------------------
// setrow() si usa come una printf per settare le righe di stampa // COME SETTARE LE RIGHE DI STAMPA
// che vengono stampate da print() // --------------------------------------------------------------
// I codici per gli argomenti variabili sono di 3 tipi: // setrow() si usa come una printf per settare le righe di stampa
// @ si usa per stampare campi di database o informazioni di controllo // che vengono stampate da print()
// posizione carrello e font // I codici per gli argomenti variabili sono di 3 tipi:
// ACHTUNG: i codici di formato sono diversi da quelli di printf e // @ si usa per stampare campi di database o informazioni di controllo
// sono elencati sotto. Per i campi di database occorre che il codice // posizione carrello e font
// sia accoppiato ad una delle funzioni FLD() passata come argomento; // ACHTUNG: i codici di formato sono diversi da quelli di printf e
// questa provoca la stampa di campi della relazione corrente, // sono elencati sotto. Per i campi di database occorre che il codice
// posizionata come e' stato deciso nell'inizializzazione // sia accoppiato ad una delle funzioni FLD() passata come argomento;
// % si usa esattamente come in una printf con un plus: se il codice di // questa provoca la stampa di campi della relazione corrente,
// formato e' maiuscolo (es. S per stringa, D per intero) viene // posizionata come e' stato deciso nell'inizializzazione
// ignorato il carattere di riempimento eventualmente specificato // % si usa esattamente come in una printf con un plus: se il codice di
// con set_fillchar. Cio' vale anche per i codici @ (vedi) // formato e' maiuscolo (es. S per stringa, D per intero) viene
// E' possibile usare due codici aggiuntivi: r(R) e t(T). A questi // ignorato il carattere di riempimento eventualmente specificato
// va fatto seguire un PUNTATORE a real o a TString. Il formato // con set_fillchar. Cio' vale anche per i codici @ (vedi)
// viene interpretato con le stesse regole di %t in dsprintf per real // E' possibile usare due codici aggiuntivi: r(R) e t(T). A questi
// (come %d o %f) e di %s per TString. Il puntatore NON // va fatto seguire un PUNTATORE a real o a TString. Il formato
// viene memorizzato; per questo occorre il codice # (sotto). // viene interpretato con le stesse regole di %t in dsprintf per real
// # si usa come % (stessi codici di printf) ma memorizza gli argomenti // (come %d o %f) e di %s per TString. Il puntatore NON
// per riferimento: ovvero, ogni volta che la riga viene stampata // viene memorizzato; per questo occorre il codice # (sotto).
// viene stampato il contenuto in quel momento (che si puo' cambiare // # si usa come % (stessi codici di printf) ma memorizza gli argomenti
// in una delle pre- o post- process). Cio' implica che: // per riferimento: ovvero, ogni volta che la riga viene stampata
// 1) gli argomenti vanno passati per RIFERIMENTO (set_row(1,"#5d",&i)) // viene stampato il contenuto in quel momento (che si puo' cambiare
// 2) i puntatori devono rimanere validi e costanti tra la set_row e // in una delle pre- o post- process). Cio' implica che:
// la fine della stampa // 1) gli argomenti vanno passati per RIFERIMENTO (set_row(1,"#5d",&i))
// Quindi, attenzione a %s con TString ridimensionate; si possono // 2) i puntatori devono rimanere validi e costanti tra la set_row e
// usare solo se predimensionate alla dimensione massima, ma e' meglio // la fine della stampa
// usare char* o il codice apposito. I codici #r e #t prendono puntatori a // Quindi, attenzione a %s con TString ridimensionate; si possono
// real e a TString, memorizzandoli. Non ci sono problemi con la resize. // usare solo se predimensionate alla dimensione massima, ma e' meglio
// Comunque, il modo corretto di adoperare il codice # e' // usare char* o il codice apposito. I codici #r e #t prendono puntatori a
// usarlo solo per stampare MEMBRI della classe derivata da TPrint_application // real e a TString, memorizzandoli. Non ci sono problemi con la resize.
// ---------------------------------------------- // Comunque, il modo corretto di adoperare il codice # e'
// field codes (match one of FLD() functions) // usarlo solo per stampare MEMBRI della classe derivata da TPrint_application
// @@ -> @ // ----------------------------------------------
// @[n[,{l|c|r}]s -> STRING: n = pad, lcr = alignment // field codes (match one of FLD() functions)
// @{[n[.d=0]]|[n[,{l|c|r}]]p}n // @@ -> @
// -> NUMBER: n = digits, d = decimals // @[n[,{l|c|r}]s -> STRING: n = pad, lcr = alignment
// p = picture string (first matching arg) // @{[n[.d=0]]|[n[,{l|c|r}]]p}n
// @[l]d -> DATE: l = full year // -> NUMBER: n = digits, d = decimals
// @f -> BOOL: prints si/no // p = picture string (first matching arg)
// @[n,{l|c|r}]t -> Translated field (must set translation) // @[l]d -> DATE: l = full year
// // @f -> BOOL: prints si/no
// Tutti questi codici possono essere usati anche maiuscoli, il che inibisce // @[n,{l|c|r}]t -> Translated field (must set translation)
// l'uso del carattere di riempimento (set_fillchar) per uno specifico campo. //
// --------------------------------------------- // Tutti questi codici possono essere usati anche maiuscoli, il che inibisce
// Per tutti i codici che riguardano la stampa di real (@n, %r, #r) // l'uso del carattere di riempimento (set_fillchar) per uno specifico campo.
// se non vengono date ulteriori specifiche di formato viene usata // ---------------------------------------------
// una picture che e' "" per default, ma puo' essere modificata con // Per tutti i codici che riguardano la stampa di real (@n, %r, #r)
// set_real_picture(). Anche questo e' assai carino. // se non vengono date ulteriori specifiche di formato viene usata
// Normalmente un real uguale a zero viene stampato come stringa vuota // una picture che e' "" per default, ma puo' essere modificata con
// a meno che non si specifichi set_print_zero([TRUE]). // set_real_picture(). Anche questo e' assai carino.
// --------------------------------------------- // Normalmente un real uguale a zero viene stampato come stringa vuota
// codici posizionamento e movimento carrello // a meno che non si specifichi set_print_zero([TRUE]).
// @<n>g vai a posizione n // ---------------------------------------------
// @<n>j salta di n posizioni (in orizzontale) // codici posizionamento e movimento carrello
// codici stile // @<n>g vai a posizione n
// @b bold // @<n>j salta di n posizioni (in orizzontale)
// @i italic // codici stile
// @u underlined // @b bold
// @r reset to normal // @i italic
// --------------------------------------------------- // @u underlined
// CODICI COLORE PER VISUALIZZAZIONE E COLLEGAMENTO // @r reset to normal
// --------------------------------------------------- // ---------------------------------------------------
// Se si vuole che in visualizzazione il testo sia colorato // CODICI COLORE PER VISUALIZZAZIONE E COLLEGAMENTO
// si usa il codice $[]; tra le quadre si scrive il colore // ---------------------------------------------------
// di foreground, opzionalmente seguito da una virgola e dal // Se si vuole che in visualizzazione il testo sia colorato
// colore di background (bianco per default). I colori si // si usa il codice $[]; tra le quadre si scrive il colore
// specificano con un singolo carattere come segue: // di foreground, opzionalmente seguito da una virgola e dal
// n nero // colore di background (bianco per default). I colori si
// g verde // specificano con un singolo carattere come segue:
// b blu // n nero
// c cyan // g verde
// y giallo // b blu
// v magenta // c cyan
// m colore background maschere (azzurrotto) // y giallo
// d grigio scuro // v magenta
// l grigio chiaro // m colore background maschere (azzurrotto)
// k grigio normale // d grigio scuro
// ------------------------------------------------------ // l grigio chiaro
// Se si fa enable_link(..) con un certo colore, tutto // k grigio normale
// cio; che e' scritto in quel colore diventa selezionabile // ------------------------------------------------------
// e alla sua selezione (premendo 'Collega') si puo' associare // Se si fa enable_link(..) con un certo colore, tutto
// un'azione in process_link. A quest'ultima viene passata // cio; che e' scritto in quel colore diventa selezionabile
// l'ID ritornata da enable_link() e il testo selezionato alla // e alla sua selezione (premendo 'Collega') si puo' associare
// pressione di Collega. Vedere ba6 e stampare l'elenco (con // un'azione in process_link. A quest'ultima viene passata
// Includi ditte abilitato) per un esempio. // l'ID ritornata da enable_link() e il testo selezionato alla
// -------------------------------------------------------- // pressione di Collega. Vedere ba6 e stampare l'elenco (con
// Includi ditte abilitato) per un esempio.
void reset_row(int r); // --------------------------------------------------------
// chiamare reset_print() durante la stampa forza la void reset_row(int r);
// rilettura di set_page() alla prossima volta
void reset_print(); // chiamare reset_print() durante la stampa forza la
// rilettura di set_page() alla prossima volta
void set_row(int r, const char* fmt, ...); void reset_print();
// --------------------------------------------- void set_row(int r, const char* fmt, ...);
// set translation values for field
// called once for each translation: example // ---------------------------------------------
// set_translation(12,"STATOCIV","1","Celibe") // set translation values for field
// provoca la stampa automatica di stringhe al // called once for each translation: example
// posto di determinati valori dei campi se e' dato // set_translation(12,"STATOCIV","1","Celibe")
// il codice @t // provoca la stampa automatica di stringhe al
// Il posto giusto per chiamarla: user_create() // posto di determinati valori dei campi se e' dato
// --------------------------------------------- // il codice @t
void set_translation(int lognum, const char* field, // Il posto giusto per chiamarla: user_create()
const char* from, const char* to); // ---------------------------------------------
void set_translation(int lognum, const char* field,
const char* from, const char* to);
// -------------------------------------------------------- // --------------------------------------------------------
// hypertext interface for viswin // hypertext interface for viswin
// -------------------------------------------------------- // --------------------------------------------------------
// Quando si vogliono abilitare determinati colori come // Quando si vogliono abilitare determinati colori come
// indicatori di legame ipertestuale, si faccia enable_link // indicatori di legame ipertestuale, si faccia enable_link
// nella create. L' ID ritornato viene passato a process_link // nella create. L' ID ritornato viene passato a process_link
// assieme al testo selezionato // assieme al testo selezionato
int enable_link (const char* descr, char fg, char bg = 'w'); int enable_link (const char* descr, char fg, char bg = 'w');
void disable_link(char fg, char bg = 'w'); void disable_link(char fg, char bg = 'w');
void disable_links() { printer().links().destroy(); } void disable_links() { printer().links().destroy(); }
// se si setta multiple a TRUE anziche' la descrizione del testo selezionato // se si setta multiple a TRUE anziche' la descrizione del testo selezionato
// viene passata a enable_link una tokenstring con tutte i 'bottoni' dello // viene passata a enable_link una tokenstring con tutte i 'bottoni' dello
// stesso colore presenti sulla riga // stesso colore presenti sulla riga
void set_multiple_link(bool on); void set_multiple_link(bool on);
// BACKGROUND PAINTING! Chefigata! poi vi spiego.... // BACKGROUND PAINTING! Chefigata! poi vi spiego....
void set_background(const char* bgdesc = NULL); void set_background(const char* bgdesc = NULL);
// --------------------------------------------- // ---------------------------------------------
// set/select cursor // set/select cursor
// --------------------------------------------- // ---------------------------------------------
// selects i-th cursor // selects i-th cursor
// inutile se c'e' un cursore solo // inutile se c'e' un cursore solo
void select_cursor(int i); void select_cursor(int i);
// return i-th cursor without making it current // return i-th cursor without making it current
TCursor* get_cursor(int i); TCursor* get_cursor(int i);
// returns maximum row defined // returns maximum row defined
int get_maxrow() { return _maxrow; } int get_maxrow() { return _maxrow; }
// adds cursor to class; return identifier // adds cursor to class; return identifier
// cursor* can be NULL: no file is used but // cursor* can be NULL: no file is used but
// print_one is called and iterations are performed // print_one is called and iterations are performed
// by pre_ and post_ process // by pre_ and post_ process
int add_cursor(TCursor* c); int add_cursor(TCursor* c);
// retrieve current cursor // retrieve current cursor
TCursor* current_cursor() { return _cur; } TCursor* current_cursor() { return _cur; }
// --------------------------------------------- // ---------------------------------------------
// set_auto_ff(TRUE) fa si' che dopo ogni pagina logica (relativa ad // set_auto_ff(TRUE) fa si' che dopo ogni pagina logica (relativa ad
// un record) si stampi un form feed. (anche se il cursore e' nullo) // un record) si stampi un form feed. (anche se il cursore e' nullo)
void set_auto_ff( bool b = TRUE) void set_auto_ff( bool b = TRUE)
{ _auto_ff = b; } { _auto_ff = b; }
// il carattere specificato con set_fillchar (default ' ') viene // il carattere specificato con set_fillchar (default ' ') viene
// usato per riempire davanti e dietro i campi in cui si e' specificata // usato per riempire davanti e dietro i campi in cui si e' specificata
// una dimensione maggiore della lunghezza effettiva del contenuto, // una dimensione maggiore della lunghezza effettiva del contenuto,
// (a meno che non si sia usato un codice di formato maiuscolo) // (a meno che non si sia usato un codice di formato maiuscolo)
void set_fillchar(char c) void set_fillchar(char c)
{ _fillchar = c; } { _fillchar = c; }
// riempie di righe vuote la pagina corrente fino alla dimensione // riempie di righe vuote la pagina corrente fino alla dimensione
// della pagina // della pagina
void fill_page(int from = -1); void fill_page(int from = -1);
// di solito basta e avanza quella di default // di solito basta e avanza quella di default
virtual bool menu(MENU_TAG m); virtual bool menu(MENU_TAG m);
// print menu is enabled when set_print returns TRUE // print menu is enabled when set_print returns TRUE
void enable_print_menu(); void enable_print_menu();
void disable_print_menu(); void disable_print_menu();
void enable_setprint_menu(); void enable_setprint_menu();
void disable_setprint_menu(); void disable_setprint_menu();
// header/footer (printf, not set_row analogues) // header/footer (printf, not set_row analogues)
// only understand @-codes for setting font attributes, // only understand @-codes for setting font attributes,
// date and page number // date and page number
// plus every printf %-code // plus every printf %-code
// con queste si possono ridefinire header e footer al // con queste si possono ridefinire header e footer al
// verificarsi di condizioni durante la stampa // verificarsi di condizioni durante la stampa
virtual void preprocess_header() {} virtual void preprocess_header() {}
virtual void preprocess_footer() {} virtual void preprocess_footer() {}
void set_header(int row, const char* fmt, ...); void set_header(int row, const char* fmt, ...);
void set_footer(int row, const char* fmt, ...); void set_footer(int row, const char* fmt, ...);
void reset_header(); void reset_header();
void reset_footer(); void reset_footer();
// vedi sopra per capire // vedi sopra per capire
void reset_files() { _reset_tree(_pr_tree); _pr_tree = NULL; } void reset_files() { _reset_tree(_pr_tree); _pr_tree = NULL; }
void add_file(int file, int from = 0); void add_file(int file, int from = 0);
void add_file(const char* tab, int from = 0); void add_file(const char* tab, int from = 0);
// set default picture for reals // set default picture for reals
void set_real_picture(const char* p) { _picture = p; } void set_real_picture(const char* p) { _picture = p; }
void set_print_zero(bool b = TRUE) { _print_zero = b; } void set_print_zero(bool b = TRUE) { _print_zero = b; }
// progress indicator control // progress indicator control
void set_wait_message(const char* m) void set_wait_message(const char* m)
{ _wmess = m; } { _wmess = m; }
void set_wait_bar(bool m) void set_wait_bar(bool m)
// default yes // default yes
{ _wbar = m; } { _wbar = m; }
void set_wait_cancel(bool m) void set_wait_cancel(bool m)
// default yes // default yes
{ _wcancel = m; } { _wcancel = m; }
void set_wait_threshold(int m) void set_wait_threshold(int m)
// minimum number of print items to show progress indicator; // minimum number of print items to show progress indicator;
// default 2 // default 2
{ _wthr = m; } { _wthr = m; }
// questa forza la progind anche se si stampa su video // questa forza la progind anche se si stampa su video
void force_progind(bool b = TRUE) void force_progind(bool b = TRUE)
{ _force_progind = b; } { _force_progind = b; }
// questa forza la rilettura delle setrow in set_page ad ogni // questa forza la rilettura delle setrow in set_page ad ogni
// record stampato, in modo che i dati siano // record stampato, in modo che i dati siano
// sempre quelli del record corrente anche se si usano codici % // sempre quelli del record corrente anche se si usano codici %
// s'intende che rallenta un po' la stampa // s'intende che rallenta un po' la stampa
void force_setpage(bool b = TRUE) void force_setpage(bool b = TRUE)
{ _force_setpage = b; } { _force_setpage = b; }
void set_config_file(const char* s) void set_config_file(const char* s)
{ _confpr = s; } { _confpr = s; }
word get_page_number() word get_page_number()
{ return printer().getcurrentpage(); } { return printer().getcurrentpage(); }
void set_page_number(word n) void set_page_number(word n)
{ printer().setcurrentpage(n); } { printer().setcurrentpage(n); }
TPrint_application();
virtual ~TPrint_application(); void set_n_copies(int n) { _ncopies = n; }
}; int get_n_copies() { return _ncopies; }
void repeat_print() { _repeat_print = TRUE; }
// buon divertimento
TPrint_application();
virtual ~TPrint_application();
#endif };
// buon divertimento
#endif

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

@ -1,141 +1,143 @@
/* This is really -*-c++-*- */ /* This is really -*-c++-*- */
#ifndef __VISWIN_H #ifndef __VISWIN_H
#define __VISWIN_H #define __VISWIN_H
#ifndef __ARRAY_H #ifndef __ARRAY_H
#include <array.h> #include <array.h>
#endif #endif
#ifndef __WINDOW_H #ifndef __WINDOW_H
#include <window.h> #include <window.h>
#endif #endif
#ifndef __STRINGS_H #ifndef __STRINGS_H
#include <strings.h> #include <strings.h>
#endif #endif
#ifndef __TEXTFILE_H #ifndef __TEXTFILE_H
#include <text.h> #include <text.h>
#endif #endif
class TViswin : public TScroll_window class TViswin : public TScroll_window
{ {
enum { MAXBUT = 4, MAXLEN = 256, BUFFERSIZE = 256, MAXPIC=4}; enum { MAXBUT = 4, MAXLEN = 256, BUFFERSIZE = 256, MAXPIC=4};
enum scroll { none, up, down, left, right }; enum scroll { none, up, down, left, right };
TFilename _filename; // name of visfile TFilename _filename; // name of visfile
bool _islink; // "link" button present bool _islink; // "link" button present
bool _isedit; // "edit" button present bool _isedit; // "edit" button present
bool _isprint; // "print" button present bool _isprint; // "print" button present
bool _iscross; // crossbars being drawn bool _iscross; // crossbars being drawn
bool _selecting; // selection in progress bool _selecting; // selection in progress
bool _isselection; // selection active bool _isselection; // selection active
bool _isbar; // X-bar drawn instead of cursor at point bool _isbar; // X-bar drawn instead of cursor at point
bool _scrolling; // scrolling in progress bool _scrolling; // scrolling in progress
bool _need_update; // full update required bool _need_update; // full update required
bool _istimer; // timer successivo attivo? bool _istimer; // timer successivo attivo?
bool _isopen; // new lines may arrive bool _isopen; // new lines may arrive
bool _selflag; bool _selflag;
bool _sel_displayed; bool _sel_displayed;
bool _link_displayed; bool _link_displayed;
bool _cross_displayed; bool _cross_displayed;
bool _point_displayed; bool _point_displayed;
long _timer; // timer per evitare autorepeat tasti long _timer; // timer per evitare autorepeat tasti
long _wtimer; // wait timer before close() long _wtimer; // wait timer before close()
scroll _need_scroll; // scrolling required? scroll _need_scroll; // scrolling required?
bool _wasneeded; // flag for smart painting bool _wasneeded; // flag for smart painting
WINDOW _button[MAXBUT]; // button array WINDOW _button[MAXBUT]; // button array
int _curbut; // button which currently has focus int _curbut; // button which currently has focus
int _buttons; // button count int _buttons; // button count
WINDOW _link_button; WINDOW _link_button;
long _textrows; // righe di testo long _textrows; // righe di testo
long _textcolumns; // indovina indovinello long _textcolumns; // indovina indovinello
TTextfile _txt; // text being displayed TTextfile _txt; // text being displayed
long _firstline; // 1rst text line being displayed long _firstline; // 1rst text line being displayed
long _lastline; // last text line being displayed long _lastline; // last text line being displayed
int _formlen; // length of a page int _formlen; // length of a page
TPoint _point; // current point position TPoint _point; // current point position
PNT _cross; // current crossbar point PNT _cross; // current crossbar point
TPoint _sel_start; // start of selection (column, line of FILE) TPoint _sel_start; // start of selection (column, line of FILE)
TPoint _sel_end; // end of selection (ibidem) TPoint _sel_end; // end of selection (ibidem)
TArray* _links; // admitted links TArray* _links; // admitted links
TArray* _hotspots; // hotspots TArray* _hotspots; // hotspots
bool need_paint_sel(bool smart = TRUE); bool need_paint_sel(bool smart = TRUE);
PICTURE _picture[MAXPIC]; // pictures PICTURE _picture[MAXPIC]; // pictures
PICTURE _modpic; PICTURE _modpic;
bool _multiple; bool _multiple;
char _linktxt[80]; char _linktxt[80];
int _linkID; int _linkID;
TToken_string _multiple_link; TToken_string _multiple_link;
TArray* _bg; TArray* _bg;
bool _isbackground; bool _isbackground;
bool _frozen; bool _frozen;
protected: protected:
virtual bool on_key (KEY); virtual bool on_key (KEY);
virtual void open(); virtual void open();
void shift_screen(scroll); void shift_screen(scroll);
void paint_screen(); void paint_screen();
void draw_crossbars(); void draw_crossbars();
void paint_header(); void paint_header();
void paint_point(bool erase = FALSE); void paint_point(bool erase = FALSE);
void paint_row(long r); void paint_row(long r);
void paint_column(long r, bool end); void paint_column(long r, bool end);
void paint_selection(); void paint_selection();
void paint_waitbar(bool xor = TRUE); void paint_waitbar(bool xor = TRUE);
void paint_background(long, int); void paint_background(long, int);
bool call_editor(); bool call_editor();
bool in_text(const TPoint& p) const; bool in_text(const TPoint& p) const;
WINDOW add_button(short id, const char* caption); WINDOW add_button(short id, const char* caption);
void repos_buttons(); void repos_buttons();
void adjust_selection(TPoint& p1, TPoint& p2); void adjust_selection(TPoint& p1, TPoint& p2);
void display_selection(); void display_selection();
void erase_selection(); void erase_selection();
void display_crossbar(); void display_crossbar();
void erase_crossbar(); void erase_crossbar();
void display_point(); void display_point();
void erase_point(); void erase_point();
bool check_link(TPoint* where = NULL); bool check_link(TPoint* where = NULL);
bool adjust_box(long& x1, long& x2, long y); bool adjust_box(long& x1, long& x2, long y);
void paint_link(long, long, long); void paint_link(long, long, long);
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; }
protected: void exec_link();
virtual void update(); protected:
virtual void handler(WINDOW win, EVENT* ep);
virtual void update();
public: virtual void handler(WINDOW win, EVENT* ep);
// gestione "collegamenti": vengono passati il testo completo, public:
// il punto di inizio selezione e quello di fine selezione; se
// non c'e' selezione non viene chiamata affatto (il bottone non fa nulla) // gestione "collegamenti": vengono passati il testo completo,
// Se serve, si faccia stop_run() qui dentro // il punto di inizio selezione e quello di fine selezione; se
virtual void process_link(TTextfile& txt, TPoint start, TPoint end) { } // non c'e' selezione non viene chiamata affatto (il bottone non fa nulla)
void close_print(); // Se serve, si faccia stop_run() qui dentro
bool frozen() { return _frozen; } virtual void process_link(TTextfile& txt, TPoint start, TPoint end) { }
void abort_print(); void close_print();
bool frozen() { return _frozen; }
void add_line(const char* l); void abort_print();
TViswin (const char* fname = NULL, void add_line(const char* l);
const char* title = NULL,
bool editbutton = TRUE, TViswin (const char* fname = NULL,
bool printbutton = TRUE, const char* title = NULL,
bool linkbutton = TRUE); bool editbutton = TRUE,
bool printbutton = TRUE,
virtual ~TViswin (); bool linkbutton = TRUE);
};
virtual ~TViswin ();
#endif };
#endif