Sistemato numero di copie nella printer; la set() chiamata dalle applicazioni

non printapp nasconde la voce n. copie a meno che non si faccia
enable_multiple_copies()


git-svn-id: svn://10.65.10.50/trunk@243 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1994-09-15 07:52:53 +00:00
parent c1e97ca1f9
commit 7c792335de
8 changed files with 1043 additions and 1046 deletions

View File

@ -1,94 +1,94 @@
#ifndef __APPLICATION_H #ifndef __APPLICATION_H
#define __APPLICATION_H #define __APPLICATION_H
#ifndef INCL_XVTH #ifndef INCL_XVTH
#include <xvt.h> #include <xvt.h>
#endif #endif
#ifndef __PRINTER_H #ifndef __PRINTER_H
#include <printer.h> #include <printer.h>
#endif #endif
#ifndef __MODAUT_H #ifndef __MODAUT_H
//#include <modaut.h> //#include <modaut.h>
#endif #endif
// @C // @C
// Classe TApplication // Classe TApplication
// @END // @END
#define MSG_AI "AI" // message auto_insert (relapp) #define MSG_AI "AI" // message auto_insert (relapp)
#define MSG_FS "FS" // message filtered start (relapp) #define MSG_FS "FS" // message filtered start (relapp)
#define MSG_LN "LN" // message (printapp -> relapp) #define MSG_LN "LN" // message (printapp -> relapp)
class TApplication class TApplication
{ {
// @DPRIV // @DPRIV
int _bar; int _bar;
int __argc; int __argc;
const char** __argv; const char** __argv;
TString80 _name, _title; TString80 _name, _title;
TPrinter* _printer; TPrinter* _printer;
protected: protected:
const char* get_module_name() const; const char* get_module_name() const;
static long task_eh(WINDOW win, EVENT* ep); static long task_eh(WINDOW win, EVENT* ep);
virtual long handler(WINDOW win, EVENT* ep); virtual long handler(WINDOW win, EVENT* ep);
virtual bool extended_firm() const { return FALSE; } // Extended set_firm dialog box? virtual bool extended_firm() const { return FALSE; } // Extended set_firm dialog box?
void terminate(); void terminate();
bool config(); bool config();
void about() const; void about() const;
public: public:
// @FPUB // @FPUB
void setbar(int menubar) { _bar = menubar;} // Modifica la menu-bar void setbar(int menubar) { _bar = menubar;} // Modifica la menu-bar
void run(int argc, char* argv[], const char* name); void run(int argc, char* argv[], const char* name);
// @DES Queste funzioni possono essere ridefinite da ogni applicazione // @DES Queste funzioni possono essere ridefinite da ogni applicazione
// @FPUB // @FPUB
virtual bool create(); // Crea la finestra principale virtual bool create(); // Crea la finestra principale
virtual bool menu(MENU_TAG) { return TRUE; } // Controlla il menu virtual bool menu(MENU_TAG) { return TRUE; } // Controlla il menu
virtual bool destroy(); // Rimuove l'applicazione virtual bool destroy(); // Rimuove l'applicazione
virtual void print(); virtual void print();
virtual word class_id() const { return CLASS_APPLICATION; } virtual word class_id() const { return CLASS_APPLICATION; }
void stop_run(); // Forza chiusura applicazione void stop_run(); // Forza chiusura applicazione
void check_menu_item(MENU_TAG item); // Check menu void check_menu_item(MENU_TAG item); // Check menu
void uncheck_menu_item(MENU_TAG item); // Uncheck void uncheck_menu_item(MENU_TAG item); // Uncheck
void enable_menu_item(MENU_TAG item, bool on = TRUE); void enable_menu_item(MENU_TAG item, bool on = TRUE);
void disable_menu_item(MENU_TAG item) { enable_menu_item(item, FALSE); } void disable_menu_item(MENU_TAG item) { enable_menu_item(item, FALSE); }
void dispatch_e_menu(MENU_TAG item); void dispatch_e_menu(MENU_TAG item);
const TString& name() const { return _name; } const TString& name() const { return _name; }
const char** argv() const { return __argv; } const char** argv() const { return __argv; }
const char* argv(int i) const { return __argv[i]; } const char* argv(int i) const { return __argv[i]; }
int argc() const { return __argc; } int argc() const { return __argc; }
void set_title(const char* t) { _title = t; } void set_title(const char* t) { _title = t; }
const char* title() const { return _title; } const char* title() const { return _title; }
void wait_for(const char* name); void wait_for(const char* name);
void wake_up_caller() const; void wake_up_caller() const;
TPrinter* set_printer(TPrinter* p); TPrinter* set_printer(TPrinter* p);
TPrinter& printer(); TPrinter& printer();
virtual bool change_config(const char* var, const char* oldv, const char* newv); virtual bool change_config(const char* var, const char* oldv, const char* newv);
bool has_module(int module) const; bool has_module(int module) const;
bool set_firm(long cod = -1); bool set_firm(long cod = -1);
long get_firm() const; long get_firm() const;
const char* get_firm_dir() const; const char* get_firm_dir() const;
TApplication(); TApplication();
virtual ~TApplication(); virtual ~TApplication();
}; };
bool xvt_running(); // xvt is running? bool xvt_running(); // xvt is running?
TApplication* MainApp(); // main application TApplication* MainApp(); // main application
#endif // __APPLICATION_H #endif // __APPLICATION_H

View File

@ -1,39 +1,39 @@
#ifndef __CLASSES_H #ifndef __CLASSES_H
#define __CLASSES_H #define __CLASSES_H
// @N // @N
// Codici identificativi delle classi // Codici identificativi delle classi
// @END // @END
// @M // @M
#define CLASS_OBJECT 1 #define CLASS_OBJECT 1
#define CLASS_ERROR 0 #define CLASS_ERROR 0
#define CLASS_SORTABLE 2 #define CLASS_SORTABLE 2
#define CLASS_STRING 10 #define CLASS_STRING 10
#define CLASS_FIXED_STRING 11 #define CLASS_FIXED_STRING 11
#define CLASS_FILENAME 12 #define CLASS_FILENAME 12
#define CLASS_TOKEN_STRING 13 #define CLASS_TOKEN_STRING 13
#define CLASS_APPLICATION 40 #define CLASS_APPLICATION 40
#define CLASS_PRINT_APPLICATION 41 #define CLASS_PRINT_APPLICATION 41
#define CLASS_PRINTROW 50 #define CLASS_PRINTROW 50
#define CLASS_PRINTER 51 #define CLASS_PRINTER 51
#define CLASS_CONTAINER 100 #define CLASS_CONTAINER 100
#define CLASS_ARRAY 101 #define CLASS_ARRAY 101
#define CLASS_STACK 102 #define CLASS_STACK 102
#define CLASS_FIELD 20 #define CLASS_FIELD 20
#define CLASS_EDIT_FIELD 21 #define CLASS_EDIT_FIELD 21
#define CLASS_REAL_FIELD 22 #define CLASS_REAL_FIELD 22
#define CLASS_DATE_FIELD 23 #define CLASS_DATE_FIELD 23
#define CLASS_BOOLEAN_FIELD 30 #define CLASS_BOOLEAN_FIELD 30
#define CLASS_LIST_FIELD 31 #define CLASS_LIST_FIELD 31
#define CLASS_RADIO_FIELD 32 #define CLASS_RADIO_FIELD 32
#define CLASS_BUTTON_FIELD 40 #define CLASS_BUTTON_FIELD 40
#define CLASS_SHEET_FIELD 50 #define CLASS_SHEET_FIELD 50
// @END // @END
#endif // __CLASSES_H #endif // __CLASSES_H

View File

@ -1,30 +1,30 @@
#ifndef _FLD_MOV_H #ifndef _FLD_MOV_H
#define _FLD_MOV_H #define _FLD_MOV_H
#define MOV_ANNOES "ANNOES" #define MOV_ANNOES "ANNOES"
#define MOV_ANNOIVA "ANNOIVA" #define MOV_ANNOIVA "ANNOIVA"
#define MOV_NUMREG "NUMREG" #define MOV_NUMREG "NUMREG"
#define MOV_DATAREG "DATAREG" #define MOV_DATAREG "DATAREG"
#define MOV_TIPO "TIPO" #define MOV_TIPO "TIPO"
#define MOV_CODCF "CODCF" #define MOV_CODCF "CODCF"
#define MOV_DATADOC "DATADOC" #define MOV_DATADOC "DATADOC"
#define MOV_NUMDOC "NUMDOC" #define MOV_NUMDOC "NUMDOC"
#define MOV_TIPODOC "TIPODOC" #define MOV_TIPODOC "TIPODOC"
#define MOV_TOTDOC "TOTDOC" #define MOV_TOTDOC "TOTDOC"
#define MOV_CODCAUS "CODCAUS" #define MOV_CODCAUS "CODCAUS"
#define MOV_DESCR "DESCR" #define MOV_DESCR "DESCR"
#define MOV_TIPOMOV "TIPOMOV" #define MOV_TIPOMOV "TIPOMOV"
#define MOV_REG "REG" #define MOV_REG "REG"
#define MOV_PROTIVA "PROTIVA" #define MOV_PROTIVA "PROTIVA"
#define MOV_UPROTIVA "UPROTIVA" #define MOV_UPROTIVA "UPROTIVA"
#define MOV_CODVAL "CODVAL" #define MOV_CODVAL "CODVAL"
#define MOV_CAMBIO "CAMBIO" #define MOV_CAMBIO "CAMBIO"
#define MOV_STAMPATO "STAMPATO" #define MOV_STAMPATO "STAMPATO"
#define MOV_NUMGIO "NUMGIO" #define MOV_NUMGIO "NUMGIO"
#define MOV_PROVVIS "PROVVIS" #define MOV_PROVVIS "PROVVIS"
#define MOV_OCFPI "OCFPI" #define MOV_OCFPI "OCFPI"
#define MOV_CORRLIRE "CORRLIRE" #define MOV_CORRLIRE "CORRLIRE"
#define MOV_CORRVALUTA "CORRVALUTA" #define MOV_CORRVALUTA "CORRVALUTA"
#define MOV_DATACOMP "DATACOMP" #define MOV_DATACOMP "DATACOMP"
#endif #endif

View File

@ -1,4 +1,4 @@
// $Id: printapp.cpp,v 1.7 1994-09-14 10:43:51 villa Exp $ // $Id: printapp.cpp,v 1.8 1994-09-15 07:52:43 villa Exp $
#include <ctype.h> #include <ctype.h>
#include <stdarg.h> #include <stdarg.h>
@ -762,10 +762,11 @@ void TPrint_application::print()
// only external apps can change it // only external apps can change it
_repeat_print = FALSE; _repeat_print = FALSE;
ncopies = printer().n_copies();
// never print multiple copies if printer is viswin // never print multiple copies if printer is viswin
// only application may repeat printing by setting _repeat_print // only application may repeat printing by setting _repeat_print
int nc = printer().printtype() == screenvis ? 1 : _ncopies; 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
@ -1242,7 +1243,6 @@ TPrint_application::TPrint_application ():TApplication (), _transtab (10),
{ {
_cur = NULL; _cur = NULL;
_repeat_print = FALSE; _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,471 +1,468 @@
// 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
// 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; bool _repeat_print;
bool _repeat_print;
// set the printer
// set the printer void set_printer() { printer().set(); }
void set_printer() { printer().set(); } // print a single record; does not advance cursor
// print a single record; does not advance cursor // returns failure or success
// returns failure or success bool print_one(int file);
bool print_one(int file); // to be documented but very fig
// to be documented but very fig bool print_tree(link_item* head);
bool print_tree(link_item* head);
static void _pp_header(TPrinter& pr);
static void _pp_header(TPrinter& pr); static void _pp_footer(TPrinter& pr);
static void _pp_footer(TPrinter& pr); static void _pp_link(int id, const char* s);
static void _pp_link(int id, const char* s);
link_item* _look_print_node(link_item* head, int logicnum);
link_item* _look_print_node(link_item* head, int logicnum); void _reset_tree(link_item* head);
void _reset_tree(link_item* head); virtual bool create();
virtual bool create(); virtual bool destroy();
virtual bool destroy();
protected:
protected:
// ****************************************************
// **************************************************** // ISTRUZIONI PER l'USO
// ISTRUZIONI PER l'USO // ****************************************************
// **************************************************** //
// // La Printapp, saggiamente, consente di operare su uno
// La Printapp, saggiamente, consente di operare su uno // o piu' cursori stampando automaticamente anche files
// o piu' cursori stampando automaticamente anche files // collegati. La sequenza delle operazioni e' la seguente:
// collegati. La sequenza delle operazioni e' la seguente: //
// // 1) Derivare una classe da TPrint_application
// 1) Derivare una classe da TPrint_application // 2) Implementare user_create() e user_destroy();
// 2) Implementare user_create() e user_destroy(); // Nella user_create() si creino i
// Nella user_create() si creino i // necessari cursori, e li si dia in pasto a Printapp
// necessari cursori, e li si dia in pasto a Printapp // usando add_cursor(). Si puo' fare add_cursor(new TCursor(...))
// usando add_cursor(). Si puo' fare add_cursor(new TCursor(...)) // dato che il cursore viene distrutto automaticamente.
// dato che il cursore viene distrutto automaticamente. // 3) Per ciascun file del cursore che si desidera porre
// 3) Per ciascun file del cursore che si desidera porre // nell'albero di stampa, si faccia add_file(logicnum [,from]);
// nell'albero di stampa, si faccia add_file(logicnum [,from]); // [from] sara' il file a cui e' collegato nella relazione.
// [from] sara' il file a cui e' collegato nella relazione. // add_file VA FATTA anche per il file principale, se no
// add_file VA FATTA anche per il file principale, se no // non stampera' nulla;
// non stampera' nulla; // *********************************************************
// ********************************************************* // FUNZIONI VIRTUALI OBBLIGATORIE
// FUNZIONI VIRTUALI OBBLIGATORIE // *********************************************************
// ********************************************************* // 4) Si definiscono le necessarie funzioni virtuali: e'
// 4) Si definiscono le necessarie funzioni virtuali: e' // sicuramente necessaria la set_page(file) nella quale
// sicuramente necessaria la set_page(file) nella quale // si metteranno (sotto if o switch) le istruzioni
// si metteranno (sotto if o switch) le istruzioni // set_row (vedi sotto) corrispondenti alla pagina
// set_row (vedi sotto) corrispondenti alla pagina // logica relativa a ciascun record di ogni file da stampare.
// logica relativa a ciascun record di ogni file da stampare. // Va definita anche set_print() in cui si presentera' ;a
// Va definita anche set_print() in cui si presentera' ;a // maschera di scelta se necessaria o una box yes_no;
// maschera di scelta se necessaria o una box yes_no; // Ritornando TRUE da set_print la stampa viene eseguita
// Ritornando TRUE da set_print la stampa viene eseguita // automaticamente (in genere ritorna FALSE se l'utente
// automaticamente (in genere ritorna FALSE se l'utente // annulla la stampa con ESC.)
// annulla la stampa con ESC.) //
// // Alla set_page, come alle pre_ e post_ process, viene
// Alla set_page, come alle pre_ e post_ process, viene // passato 0 se il cursore attuale e' nullo (vedi sotto).
// passato 0 se il cursore attuale e' nullo (vedi sotto). // *********************************************************
// ********************************************************* // FUNZIONI VIRTUALI FACOLTATIVE
// FUNZIONI VIRTUALI FACOLTATIVE // *********************************************************
// ********************************************************* // 5) Le varie funzioni pre_ e post_ process _page e _print
// 5) Le varie funzioni pre_ e post_ process _page e _print // vengono chiamate prima e dopo la stampa di ogni record
// vengono chiamate prima e dopo la stampa di ogni record // o gruppo di record relativo alla relazione immessa;
// o gruppo di record relativo alla relazione immessa; // ad esempio, postprocess_print() viene chiamata per il
// ad esempio, postprocess_print() viene chiamata per il // file principale una volta dopo l'intera stampa; per
// file principale una volta dopo l'intera stampa; per // un file collegato nella relazione, e' chiamata tante
// un file collegato nella relazione, e' chiamata tante // volte quanti gruppi di almeno un record esistono per
// volte quanti gruppi di almeno un record esistono per // record del file genitore. Qui si possono modificare
// record del file genitore. Qui si possono modificare // righe, calcolare totali etc. A queste funzioni
// righe, calcolare totali etc. A queste funzioni // viene sempre passato il file (logicnum) in corso di stampa e
// viene sempre passato il file (logicnum) in corso di stampa e // un contatore che indica quante volte la stampa e' stata
// un contatore che indica quante volte la stampa e' stata // ripetuta. le pre_ ritornano TRUE o FALSE, nell'ultimo
// ripetuta. le pre_ ritornano TRUE o FALSE, nell'ultimo // caso interrompono la stampa; le post_ ritornano
// caso interrompono la stampa; le post_ ritornano // NEXT_PAGE (comportamento normale) o REPEAT_PAGE
// NEXT_PAGE (comportamento normale) o REPEAT_PAGE // (indovina cosa fa).
// (indovina cosa fa). // 6) set_print() viene chiamata dalla voce Selezione,
// 6) set_print() viene chiamata dalla voce Selezione, // unica del secondo menu. E' il posto dove mettere
// unica del secondo menu. E' il posto dove mettere // una buona maschera di selezione di cosa stampare.
// una buona maschera di selezione di cosa stampare. // Alla fine, si esegua enable_print_menu() per
// Alla fine, si esegua enable_print_menu() per // abilitare la voce Stampa, inizialmente inattiva.
// abilitare la voce Stampa, inizialmente inattiva. // 7) cancel_hook() permette di intercettare la
// 7) cancel_hook() permette di intercettare la // cancellazione della stampa; ritornando TRUE
// cancellazione della stampa; ritornando TRUE // la stampa viene effettivamente cancellata
// la stampa viene effettivamente cancellata // Tutti i parametri relativi al progress indicator
// Tutti i parametri relativi al progress indicator // vengono settati da funzioni apposite (vedi oltre)
// vengono settati da funzioni apposite (vedi oltre) // ****************************************************
// **************************************************** // Molte altre minchiatine (form feed automatici, header,
// Molte altre minchiatine (form feed automatici, header, // footer etc) sono spiegate nel seguito
// footer etc) sono spiegate nel seguito // ****************************************************
// ****************************************************
virtual void user_create() {}
virtual void user_create() {} virtual void user_destroy() {}
virtual void user_destroy() {}
// set print, bound to menu :Selezione:Stampa
// set print, bound to menu :Selezione:Stampa // chiamata automaticamente dopo user_create()
// chiamata automaticamente dopo user_create() virtual bool set_print(int i = 1) { return FALSE; }
virtual bool set_print(int i = 1) { return FALSE; }
// set_row functions MUST be called here in a switch
// set_row functions MUST be called here in a switch // for each particular file being printed
// for each particular file being printed virtual void set_page(int file, int cnt) {}
virtual void set_page(int file, int cnt) {}
// called before processing each page
// called before processing each page // used to set print strings from tables or files
// used to set print strings from tables or files // not included in relation
// not included in relation // returning FALSE cancels page printing
// returning FALSE cancels page printing // counter is the current print page number
// counter is the current print page number virtual bool preprocess_page(int file, int counter)
virtual bool preprocess_page(int file, int counter) { return TRUE; }
{ return TRUE; }
// same before each print request
// same before each print request // e.g. to initialize counters
// e.g. to initialize counters // returning FALSE cancels print request or subtree
// returning FALSE cancels print request or subtree virtual bool preprocess_print(int file, int counter)
virtual bool preprocess_print(int file, int counter) { return TRUE; }
{ return TRUE; }
// postprocessing; returning REPEAT_PAGE reprints the
// postprocessing; returning REPEAT_PAGE reprints the // whole page (after all sons are printed) or print
// whole page (after all sons are printed) or print // counter is the current page or print number
// counter is the current page or print number virtual print_action postprocess_page(int file, int counter)
virtual print_action postprocess_page(int file, int counter) { return NEXT_PAGE; }
{ return NEXT_PAGE; } virtual print_action postprocess_print(int file, int counter)
virtual print_action postprocess_print(int file, int counter) { return NEXT_PAGE; }
{ return NEXT_PAGE; } // executed after all print job is completed
// executed after all print job is completed virtual void postclose_print() {}
virtual void postclose_print() {}
// called when LINK button is pressed with active selection in
// called when LINK button is pressed with active selection in // preview window
// preview window virtual void process_link(int id, const char* text) {}
virtual void process_link(int id, const char* text) {}
// called when user cancels print; returning TRUE
// called when user cancels print; returning TRUE // actually stops printing; not called if no cancel
// actually stops printing; not called if no cancel virtual bool cancel_hook() {return TRUE;}
virtual bool cancel_hook() {return TRUE;}
// bound to TApplication print menu
// bound to TApplication print menu // redefined ONLY for very special purposes
// redefined ONLY for very special purposes virtual void print();
virtual void print();
// bound to <select> menu and automatically called after
// bound to <select> menu and automatically called after // user_create()
// user_create() void do_print(int n);
void do_print(int n);
public:
public:
// --------------------------------------------------------------
// -------------------------------------------------------------- // COME SETTARE LE RIGHE DI STAMPA
// COME SETTARE LE RIGHE DI STAMPA // --------------------------------------------------------------
// -------------------------------------------------------------- // setrow() si usa come una printf per settare le righe di stampa
// setrow() si usa come una printf per settare le righe di stampa // che vengono stampate da print()
// che vengono stampate da print() // I codici per gli argomenti variabili sono di 3 tipi:
// I codici per gli argomenti variabili sono di 3 tipi: // @ si usa per stampare campi di database o informazioni di controllo
// @ si usa per stampare campi di database o informazioni di controllo // posizione carrello e font
// posizione carrello e font // ACHTUNG: i codici di formato sono diversi da quelli di printf e
// ACHTUNG: i codici di formato sono diversi da quelli di printf e // sono elencati sotto. Per i campi di database occorre che il codice
// sono elencati sotto. Per i campi di database occorre che il codice // sia accoppiato ad una delle funzioni FLD() passata come argomento;
// sia accoppiato ad una delle funzioni FLD() passata come argomento; // questa provoca la stampa di campi della relazione corrente,
// questa provoca la stampa di campi della relazione corrente, // posizionata come e' stato deciso nell'inizializzazione
// posizionata come e' stato deciso nell'inizializzazione // % si usa esattamente come in una printf con un plus: se il codice di
// % si usa esattamente come in una printf con un plus: se il codice di // formato e' maiuscolo (es. S per stringa, D per intero) viene
// formato e' maiuscolo (es. S per stringa, D per intero) viene // ignorato il carattere di riempimento eventualmente specificato
// ignorato il carattere di riempimento eventualmente specificato // con set_fillchar. Cio' vale anche per i codici @ (vedi)
// con set_fillchar. Cio' vale anche per i codici @ (vedi) // E' possibile usare due codici aggiuntivi: r(R) e t(T). A questi
// E' possibile usare due codici aggiuntivi: r(R) e t(T). A questi // va fatto seguire un PUNTATORE a real o a TString. Il formato
// va fatto seguire un PUNTATORE a real o a TString. Il formato // viene interpretato con le stesse regole di %t in dsprintf per real
// viene interpretato con le stesse regole di %t in dsprintf per real // (come %d o %f) e di %s per TString. Il puntatore NON
// (come %d o %f) e di %s per TString. Il puntatore NON // viene memorizzato; per questo occorre il codice # (sotto).
// viene memorizzato; per questo occorre il codice # (sotto). // # si usa come % (stessi codici di printf) ma memorizza gli argomenti
// # si usa come % (stessi codici di printf) ma memorizza gli argomenti // per riferimento: ovvero, ogni volta che la riga viene stampata
// per riferimento: ovvero, ogni volta che la riga viene stampata // viene stampato il contenuto in quel momento (che si puo' cambiare
// viene stampato il contenuto in quel momento (che si puo' cambiare // in una delle pre- o post- process). Cio' implica che:
// in una delle pre- o post- process). Cio' implica che: // 1) gli argomenti vanno passati per RIFERIMENTO (set_row(1,"#5d",&i))
// 1) gli argomenti vanno passati per RIFERIMENTO (set_row(1,"#5d",&i)) // 2) i puntatori devono rimanere validi e costanti tra la set_row e
// 2) i puntatori devono rimanere validi e costanti tra la set_row e // la fine della stampa
// la fine della stampa // Quindi, attenzione a %s con TString ridimensionate; si possono
// Quindi, attenzione a %s con TString ridimensionate; si possono // usare solo se predimensionate alla dimensione massima, ma e' meglio
// usare solo se predimensionate alla dimensione massima, ma e' meglio // usare char* o il codice apposito. I codici #r e #t prendono puntatori a
// usare char* o il codice apposito. I codici #r e #t prendono puntatori a // real e a TString, memorizzandoli. Non ci sono problemi con la resize.
// real e a TString, memorizzandoli. Non ci sono problemi con la resize. // Comunque, il modo corretto di adoperare il codice # e'
// Comunque, il modo corretto di adoperare il codice # e' // usarlo solo per stampare MEMBRI della classe derivata da TPrint_application
// usarlo solo per stampare MEMBRI della classe derivata da TPrint_application // ----------------------------------------------
// ---------------------------------------------- // field codes (match one of FLD() functions)
// field codes (match one of FLD() functions) // @@ -> @
// @@ -> @ // @[n[,{l|c|r}]s -> STRING: n = pad, lcr = alignment
// @[n[,{l|c|r}]s -> STRING: n = pad, lcr = alignment // @{[n[.d=0]]|[n[,{l|c|r}]]p}n
// @{[n[.d=0]]|[n[,{l|c|r}]]p}n // -> NUMBER: n = digits, d = decimals
// -> NUMBER: n = digits, d = decimals // p = picture string (first matching arg)
// p = picture string (first matching arg) // @[l]d -> DATE: l = full year
// @[l]d -> DATE: l = full year // @f -> BOOL: prints si/no
// @f -> BOOL: prints si/no // @[n,{l|c|r}]t -> Translated field (must set translation)
// @[n,{l|c|r}]t -> Translated field (must set translation) //
// // Tutti questi codici possono essere usati anche maiuscoli, il che inibisce
// Tutti questi codici possono essere usati anche maiuscoli, il che inibisce // l'uso del carattere di riempimento (set_fillchar) per uno specifico campo.
// l'uso del carattere di riempimento (set_fillchar) per uno specifico campo. // ---------------------------------------------
// --------------------------------------------- // Per tutti i codici che riguardano la stampa di real (@n, %r, #r)
// Per tutti i codici che riguardano la stampa di real (@n, %r, #r) // se non vengono date ulteriori specifiche di formato viene usata
// se non vengono date ulteriori specifiche di formato viene usata // una picture che e' "" per default, ma puo' essere modificata con
// una picture che e' "" per default, ma puo' essere modificata con // set_real_picture(). Anche questo e' assai carino.
// set_real_picture(). Anche questo e' assai carino. // Normalmente un real uguale a zero viene stampato come stringa vuota
// Normalmente un real uguale a zero viene stampato come stringa vuota // a meno che non si specifichi set_print_zero([TRUE]).
// a meno che non si specifichi set_print_zero([TRUE]). // ---------------------------------------------
// --------------------------------------------- // codici posizionamento e movimento carrello
// codici posizionamento e movimento carrello // @<n>g vai a posizione n
// @<n>g vai a posizione n // @<n>j salta di n posizioni (in orizzontale)
// @<n>j salta di n posizioni (in orizzontale) // codici stile
// codici stile // @b bold
// @b bold // @i italic
// @i italic // @u underlined
// @u underlined // @r reset to normal
// @r reset to normal // ---------------------------------------------------
// --------------------------------------------------- // CODICI COLORE PER VISUALIZZAZIONE E COLLEGAMENTO
// CODICI COLORE PER VISUALIZZAZIONE E COLLEGAMENTO // ---------------------------------------------------
// --------------------------------------------------- // Se si vuole che in visualizzazione il testo sia colorato
// Se si vuole che in visualizzazione il testo sia colorato // si usa il codice $[]; tra le quadre si scrive il colore
// si usa il codice $[]; tra le quadre si scrive il colore // di foreground, opzionalmente seguito da una virgola e dal
// di foreground, opzionalmente seguito da una virgola e dal // colore di background (bianco per default). I colori si
// colore di background (bianco per default). I colori si // specificano con un singolo carattere come segue:
// specificano con un singolo carattere come segue: // n nero
// n nero // g verde
// g verde // b blu
// b blu // c cyan
// c cyan // y giallo
// y giallo // v magenta
// v magenta // m colore background maschere (azzurrotto)
// m colore background maschere (azzurrotto) // d grigio scuro
// d grigio scuro // l grigio chiaro
// l grigio chiaro // k grigio normale
// k grigio normale // ------------------------------------------------------
// ------------------------------------------------------ // Se si fa enable_link(..) con un certo colore, tutto
// Se si fa enable_link(..) con un certo colore, tutto // cio; che e' scritto in quel colore diventa selezionabile
// cio; che e' scritto in quel colore diventa selezionabile // e alla sua selezione (premendo 'Collega') si puo' associare
// e alla sua selezione (premendo 'Collega') si puo' associare // un'azione in process_link. A quest'ultima viene passata
// un'azione in process_link. A quest'ultima viene passata // l'ID ritornata da enable_link() e il testo selezionato alla
// l'ID ritornata da enable_link() e il testo selezionato alla // pressione di Collega. Vedere ba6 e stampare l'elenco (con
// pressione di Collega. Vedere ba6 e stampare l'elenco (con // Includi ditte abilitato) per un esempio.
// Includi ditte abilitato) per un esempio. // --------------------------------------------------------
// --------------------------------------------------------
void reset_row(int r);
void reset_row(int r);
// chiamare reset_print() durante la stampa forza la
// chiamare reset_print() durante la stampa forza la // rilettura di set_page() alla prossima volta
// rilettura di set_page() alla prossima volta void reset_print();
void reset_print();
void set_row(int r, const char* fmt, ...);
void set_row(int r, const char* fmt, ...);
// ---------------------------------------------
// --------------------------------------------- // set translation values for field
// set translation values for field // called once for each translation: example
// called once for each translation: example // set_translation(12,"STATOCIV","1","Celibe")
// set_translation(12,"STATOCIV","1","Celibe") // provoca la stampa automatica di stringhe al
// provoca la stampa automatica di stringhe al // posto di determinati valori dei campi se e' dato
// posto di determinati valori dei campi se e' dato // il codice @t
// il codice @t // Il posto giusto per chiamarla: user_create()
// Il posto giusto per chiamarla: user_create() // ---------------------------------------------
// --------------------------------------------- void set_translation(int lognum, const char* field,
void set_translation(int lognum, const char* field, const char* from, const char* to);
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);
virtual word class_id() const { return CLASS_PRINT_APPLICATION; }
virtual word class_id() const { return CLASS_PRINT_APPLICATION; }
// 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); }
void repeat_print() { _repeat_print = TRUE; }
void set_n_copies(int n) { _ncopies = n; }
int get_n_copies() { return _ncopies; } TPrint_application();
void repeat_print() { _repeat_print = TRUE; } virtual ~TPrint_application();
};
TPrint_application();
virtual ~TPrint_application(); // buon divertimento
};
// buon divertimento #endif
#endif

View File

@ -642,7 +642,7 @@ bool set_windows_print_device (TMask_field & f, KEY key)
TPrinter::TPrinter() TPrinter::TPrinter()
: _date (TODAY), _multiple_link (FALSE), _frozen (FALSE), _isgraphics (TRUE), : _date (TODAY), _multiple_link (FALSE), _frozen (FALSE), _isgraphics (TRUE),
_lines_per_inch (6), _ch_size (12) _lines_per_inch (6), _ch_size (12), _ncopies(1)
{ {
_footerhandler = _headerhandler = NULL; _footerhandler = _headerhandler = NULL;
@ -662,6 +662,8 @@ TPrinter::TPrinter()
_headersize = 0; _headersize = 0;
_footersize = 0; _footersize = 0;
_isopen = FALSE; _isopen = FALSE;
_multiple_copies = MainApp()->class_id() == CLASS_PRINTER_APPLICATION;
// read configuration file // read configuration file
read_configuration (_config); read_configuration (_config);
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
@ -1148,7 +1150,8 @@ void TPrinter::set()
((TList_field &) (mask.field (MSK_1_PRINTERS))).replace_items (pn1, pn2); ((TList_field &) (mask.field (MSK_1_PRINTERS))).replace_items (pn1, pn2);
mask.hide(MSK_1_SETUP); mask.hide(MSK_1_SETUP);
mask.hide(MSK_1_SIZE); mask.hide(MSK_1_SIZE);
mask.hide(MSK_1_LINES); mask.hide(MSK_1_LINES);
if (!_multiple_copies) mask.hide(MSK_1_NPAGES);
pn1 = ""; pn1 = "";
pn2 = ""; pn2 = "";
@ -1171,11 +1174,7 @@ void TPrinter::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, _ncopies);
int nc = 1;
if (MainApp()->class_id() == CLASS_PRINT_APPLICATION)
nc = ((TPrint_application*)MainApp())->get_n_copies();
mask.set(MSK_1_NPAGES, nc);
mask.reset (MSK_1_SAVE); mask.reset (MSK_1_SAVE);
@ -1195,9 +1194,7 @@ void TPrinter::set()
// get user choices // get user choices
_curprn = atoi(mask.get(MSK_1_PRINTERS)); _curprn = atoi(mask.get(MSK_1_PRINTERS));
_ncopies = atoi(mask.get(MSK_1_NPAGES));
if (MainApp()->class_id() == CLASS_PRINT_APPLICATION)
((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)))
@ -1241,15 +1238,15 @@ void TPrinter::set()
((TList_field &) (mask.field (MSK_1_PRINTERS))).replace_items(pn1, pn2); ((TList_field &) (mask.field (MSK_1_PRINTERS))).replace_items(pn1, pn2);
mask.set(MSK_1_PRINTERS, pn1.get(_curprn)); mask.set(MSK_1_PRINTERS, pn1.get(_curprn));
mask.hide(MSK_1_CODES); mask.hide(MSK_1_CODES);
if (!_multiple_copies) mask.hide(MSK_1_NPAGES);
mask.set(MSK_1_ISGRAPHICS, _isgraphics ? "X" : ""); mask.set(MSK_1_ISGRAPHICS, _isgraphics ? "X" : "");
mask.set(MSK_1_SIZE, _ch_size); mask.set(MSK_1_SIZE, _ch_size);
mask.set(MSK_1_LINES, _lines_per_inch); mask.set(MSK_1_LINES, _lines_per_inch);
int nc = 1; mask.set(MSK_1_NPAGES, _ncopies);
if (MainApp()->class_id() == CLASS_PRINT_APPLICATION)
nc = ((TPrint_application*)MainApp())->get_n_copies();
mask.set(MSK_1_NPAGES, nc);
if (_printertype == fileprinter) if (_printertype == fileprinter)
mask.set (MSK_1_TYPE, "1"); mask.set (MSK_1_TYPE, "1");
@ -1312,8 +1309,7 @@ void TPrinter::set()
mask.save (); mask.save ();
} }
if (MainApp()->class_id() == CLASS_PRINT_APPLICATION) _ncopies = atoi (mask.get (MSK_1_NPAGES));
((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)))
{ {

View File

@ -1,357 +1,361 @@
#ifndef __PRINTER_H #ifndef __PRINTER_H
#define __PRINTER_H #define __PRINTER_H
#ifndef __STDIO_H #ifndef __STDIO_H
#include <stdio.h> #include <stdio.h>
#endif #endif
#ifndef __STRINGS_H #ifndef __STRINGS_H
#include <strings.h> #include <strings.h>
#endif #endif
#ifndef __ARRAY_H #ifndef __ARRAY_H
#include <array.h> #include <array.h>
#endif #endif
#ifndef __VISWIN_H #ifndef __VISWIN_H
#include <viswin.h> #include <viswin.h>
#endif #endif
#ifndef __DATE_H #ifndef __DATE_H
#include <date.h> #include <date.h>
#endif #endif
#ifndef __PRINTWIN_H #ifndef __PRINTWIN_H
#include <printwin.h> #include <printwin.h>
#endif #endif
#ifndef __TEXT_H #ifndef __TEXT_H
#include <text.h> #include <text.h>
#endif #endif
// @DPUB // @DPUB
enum TPrintstyle { enum TPrintstyle {
normalstyle = 0, normalstyle = 0,
boldstyle = 1, boldstyle = 1,
underlinedstyle = 2, underlinedstyle = 2,
italicstyle = 3 italicstyle = 3
}; };
enum TPrtype { enum TPrtype {
normprinter = 0, normprinter = 0,
fileprinter = 1, fileprinter = 1,
spoolprinter = 2, spoolprinter = 2,
localprinter = 3, localprinter = 3,
screenvis = 4, screenvis = 4,
winprinter = 5 winprinter = 5
}; };
// @END // @END
// @C // @C
// class TPrintrow : public TObject // class TPrintrow : public TObject
// @END // @END
class TPrintrow : public TObject class TPrintrow : public TObject
{ {
enum { MAXSTR = 256 }; enum { MAXSTR = 256 };
// @DPROT // @DPROT
TString256 _row; // the actual string to print TString256 _row; // the actual string to print
char _attr[MAXSTR]; // contains char attributes of _row char _attr[MAXSTR]; // contains char attributes of _row
int _cols[MAXSTR]; // contains color attributes of _row int _cols[MAXSTR]; // contains color attributes of _row
TPrintstyle _currentstyle; // the current char attribute TPrintstyle _currentstyle; // the current char attribute
int _currentcolor; // the current color attribute int _currentcolor; // the current color attribute
int _lastpos; // last print position int _lastpos; // last print position
public: public:
// @FPUB // @FPUB
TPrintrow(); TPrintrow();
TPrintrow(const TPrintrow& pr); TPrintrow(const TPrintrow& pr);
virtual ~TPrintrow() {} virtual ~TPrintrow() {}
// TPrintrow& center(const char* str, int position); // TPrintrow& center(const char* str, int position);
virtual word class_id() const; virtual word class_id() const;
virtual const char* class_name() const; virtual const char* class_name() const;
virtual TObject* dup() const; virtual TObject* dup() const;
const char* row() const { return _row; } const char* row() const { return _row; }
const char* row_codified(); const char* row_codified();
TPrintrow& reset(); TPrintrow& reset();
TPrintstyle get_style(int position) const { return (TPrintstyle)_attr[position]; } TPrintstyle get_style(int position) const { return (TPrintstyle)_attr[position]; }
TPrintstyle get_style() const { return _currentstyle; } TPrintstyle get_style() const { return _currentstyle; }
int get_color(int position) const { return (TPrintstyle)_cols[position]; } int get_color(int position) const { return (TPrintstyle)_cols[position]; }
int get_color() const { return _currentcolor; } int get_color() const { return _currentcolor; }
TPrintrow& put(const char* str, int position = -1, int len=0); TPrintrow& put(const char* str, int position = -1, int len=0);
void set_style(TPrintstyle style) { _currentstyle=style; } void set_style(TPrintstyle style) { _currentstyle=style; }
int lastpos() const { return _lastpos; } int lastpos() const { return _lastpos; }
}; };
class PrinterDef : public TObject class PrinterDef : public TObject
{ {
friend class TPrinter; friend class TPrinter;
TString _printername; // name of the printer file TString _printername; // name of the printer file
TString _printertype; // type of printer (0=diretta,1=locale,2=spool) TString _printertype; // type of printer (0=diretta,1=locale,2=spool)
TString _filtername; // filter for the pipe (UNIX only) TString _filtername; // filter for the pipe (UNIX only)
TString _devicename; // name of print device TString _devicename; // name of print device
char _atstr[4][10]; // attribute codes for the current printer char _atstr[4][10]; // attribute codes for the current printer
TArray _codes; // print codes TArray _codes; // print codes
TArray _names; // name of print codes TArray _names; // name of print codes
TString _ffcode; // formfeed code for the current printer TString _ffcode; // formfeed code for the current printer
TString _nlcode; // special newline code for the current printer TString _nlcode; // special newline code for the current printer
public: public:
bool read(const char* name, FILE* fd); // read description from file; bool read(const char* name, FILE* fd); // read description from file;
bool isdefault(); // name matches "Default" bool isdefault(); // name matches "Default"
const char* get_codenames(word i) const { return i < (word) _names.items() ? (const char*)(TString&)_names[i] : NULL; } const char* get_codenames(word i) const { return i < (word) _names.items() ? (const char*)(TString&)_names[i] : NULL; }
const char* get_codes(word i) const { return i < (word) _codes.items() ? (const char*)(TString&)_codes[i] : NULL; } const char* get_codes(word i) const { return i < (word) _codes.items() ? (const char*)(TString&)_codes[i] : NULL; }
PrinterDef() : _printername(10), _filtername(10), PrinterDef() : _printername(10), _filtername(10),
_ffcode("\f"), _nlcode("\n") _ffcode("\f"), _nlcode("\n")
{} {}
}; };
class TPrinter; class TPrinter;
typedef void (*PRINTSECTIONHANDLER)(TPrinter& printer); typedef void (*PRINTSECTIONHANDLER)(TPrinter& printer);
typedef void (*LINKHANDLER)(int, const char*); typedef void (*LINKHANDLER)(int, const char*);
// @C // @C
// class TPrinter : public TObject // class TPrinter : public TObject
// @END // @END
class TPrinter : public TObject class TPrinter : public TObject
{ {
// @DPROT // @DPROT
FILE* _cnfptr; // config file FILE* _cnfptr; // config file
FILE* _fp; // pointer to the printer file FILE* _fp; // pointer to the printer file
TViswin* _vf; // pointer to file visualizer TViswin* _vf; // pointer to file visualizer
TTextfile _txt; TTextfile _txt;
TFilename _config; // name of the configuration file TFilename _config; // name of the configuration file
int _headersize; int _headersize;
int _footersize; int _footersize;
TArray _header; TArray _header;
TArray _footer; TArray _footer;
TArray _printers; // printers descriptions TArray _printers; // printers descriptions
int _curprn; // current printer index int _curprn; // current printer index
int _curcode; // current printer index int _curcode; // current printer index
int _formlen; // length of the logic page int _formlen; // length of the logic page
int _currentrow; // next row to print int _currentrow; // next row to print
int _ch_size; int _ch_size;
word _currentpage; // logic page containing _currentrow word _currentpage; // logic page containing _currentrow
word _frompage; // first page to print (normally 0) word _frompage; // first page to print (normally 0)
word _topage; // last page to print (normally = USHRT_MAX) word _topage; // last page to print (normally = USHRT_MAX)
bool _hwformfeed; // if TRUE a ff will be printed after any footer bool _hwformfeed; // if TRUE a ff will be printed after any footer
TPrtype _printertype; // specifies the kind of output the user wants TPrtype _printertype; // specifies the kind of output the user wants
bool _isopen; // printer open bool _isopen; // printer open
TDate _date; // printing date TDate _date; // printing date
TFilename _printerfile; // filename for printing on file TFilename _printerfile; // filename for printing on file
TArray _linksdescr; TArray _linksdescr;
bool _multiple_link; // bool _multiple_link; //
TArray _background; TArray _background;
const char* _bg_desc; const char* _bg_desc;
TToken_string _printer_names; TToken_string _printer_names;
bool _isgraphics; bool _isgraphics;
bool _frozen; bool _frozen;
#if XVT_OS == XVT_OS_WIN int _ncopies;
PRINT_RCD* _print_rcd; #if XVT_OS == XVT_OS_WIN
int _print_rcd_size; PRINT_RCD* _print_rcd;
#endif int _print_rcd_size;
int _lines_per_inch; #endif
int _vert_offset; int _lines_per_inch;
int _horz_offset; int _vert_offset;
int _dots_per_line; int _horz_offset;
int _dots_per_line;
void _parse_background();
void _get_windows_printer_names(TToken_string& t); void _parse_background();
void _get_windows_printer_names(TToken_string& t);
PRINTSECTIONHANDLER _headerhandler, _footerhandler; bool _multiple_copies;
LINKHANDLER _linkhandler;
PRINTSECTIONHANDLER _headerhandler, _footerhandler;
// @END LINKHANDLER _linkhandler;
// @FPROT // @END
protected:
virtual char newline() { return '\n'; } // @FPROT
bool printrow (TPrintrow* rowtoprint=NULL); // base methods for printing protected:
bool printformfeed (); virtual char newline() { return '\n'; }
void read_configuration(const char* cfg); bool printrow (TPrintrow* rowtoprint=NULL); // base methods for printing
bool printformfeed ();
bool printheader(); void read_configuration(const char* cfg);
bool printfooter();
bool printheader();
public: bool printfooter();
// @FPUB public:
TPrinter ();
virtual ~TPrinter(); // @FPUB
TPrinter ();
#if XVT_OS == XVT_OS_WIN virtual ~TPrinter();
static BOOLEAN start_winprint(long);
#if XVT_OS == XVT_OS_WIN
#endif static BOOLEAN start_winprint(long);
void set_config_file (const char * ffile) { _config = ffile ; }
void set_from_page (word from) { _frompage = from; } #endif
void set_to_page (word to) { _topage = to; } void set_config_file (const char * ffile) { _config = ffile ; }
void set_hwff (bool hwff) { _hwformfeed = hwff; } void set_from_page (word from) { _frompage = from; }
void set_to_page (word to) { _topage = to; }
int descriptions() void set_hwff (bool hwff) { _hwformfeed = hwff; }
{ return _printers.items(); }
const PrinterDef& get_description(word i) const int descriptions()
{ return (const PrinterDef&) _printers[i]; } { return _printers.items(); }
virtual const char* class_name() const; const PrinterDef& get_description(word i) const
virtual word class_id() const; { return (const PrinterDef&) _printers[i]; }
virtual const char* class_name() const;
int formlen () const { return _formlen; } virtual word class_id() const;
word frompage () const { return _frompage; }
word topage () const { return _topage; } int formlen () const { return _formlen; }
int headersize () const { return _headersize; } word frompage () const { return _frompage; }
int footersize () const { return _footersize; } word topage () const { return _topage; }
TPrintrow* getheaderline (int linetoget); int headersize () const { return _headersize; }
TPrintrow* getfooterline (int linetoget); int footersize () const { return _footersize; }
int formlen (int fl) { return (_formlen=fl); } TPrintrow* getheaderline (int linetoget);
int footerlen (int fl) { return (_footersize=fl); } TPrintrow* getfooterline (int linetoget);
int headerlen (int hl) { return (_headersize=hl); } int formlen (int fl) { return (_formlen=fl); }
word frompage (word fp) { return (_frompage=fp);} int footerlen (int fl) { return (_footersize=fl); }
word topage (word tp) { return (_topage=tp); } int headerlen (int hl) { return (_headersize=hl); }
void setheaderline (int linetoset, TPrintrow* line); word frompage (word fp) { return (_frompage=fp);}
void setheaderline (int linetoset, const TPrintrow& line); word topage (word tp) { return (_topage=tp); }
void setfooterline (int linetoset, TPrintrow* line); void setheaderline (int linetoset, TPrintrow* line);
void setfooterline (int linetoset, const TPrintrow& line); void setheaderline (int linetoset, const TPrintrow& line);
void resetheader(); void setfooterline (int linetoset, TPrintrow* line);
void resetfooter(); void setfooterline (int linetoset, const TPrintrow& line);
void setbackground(const char* bg); void resetheader();
TArray* getbgdesc() { return &_background; } void resetfooter();
bool frozen() { return _frozen; } void setbackground(const char* bg);
void freeze(bool b = TRUE) { _frozen = b; } TArray* getbgdesc() { return &_background; }
bool frozen() { return _frozen; }
TToken_string& getprinternames(); void freeze(bool b = TRUE) { _frozen = b; }
TTextfile& get_txt() { return _txt; } int n_copies() { return _ncopies; }
void enable_multiple_copies(bool b = TRUE) { _multiple_copies = b; }
void setheaderhandler(PRINTSECTIONHANDLER h) { _headerhandler = h; }
void setfooterhandler(PRINTSECTIONHANDLER h) { _footerhandler = h; } TToken_string& getprinternames();
TTextfile& get_txt() { return _txt; }
// used by viswin()
// sono qui e non nella printapp per poter usare una viswin void setheaderhandler(PRINTSECTIONHANDLER h) { _headerhandler = h; }
// completamente anche da un'altra application void setfooterhandler(PRINTSECTIONHANDLER h) { _footerhandler = h; }
void setlinkhandler(LINKHANDLER h) { _linkhandler = h; }
LINKHANDLER getlinkhandler() { return _linkhandler; } // used by viswin()
TArray& links() { return _linksdescr; } // sono qui e non nella printapp per poter usare una viswin
void setmultiplelink(bool on) { _multiple_link = on; } // completamente anche da un'altra application
bool ismultiplelink() { return _multiple_link; } void setlinkhandler(LINKHANDLER h) { _linkhandler = h; }
LINKHANDLER getlinkhandler() { return _linkhandler; }
bool skip (int linetoskip); TArray& links() { return _linksdescr; }
bool jump (int linestojump); void setmultiplelink(bool on) { _multiple_link = on; }
void reset (); bool ismultiplelink() { return _multiple_link; }
virtual void set ();
bool open (); bool skip (int linetoskip);
void close (); bool jump (int linestojump);
bool formfeed (); void reset ();
bool print (TPrintrow& rowtoprint); virtual void set ();
bool isopen() { return _isopen; } bool open ();
void setdate(TDate& d) { _date = d; } void close ();
TPrtype printtype() { return _printertype; } bool formfeed ();
void set_printtype(TPrtype dest) { _printertype=dest; } bool print (TPrintrow& rowtoprint);
void set_printerfile(const char * ffile) { _printerfile=ffile; } bool isopen() { return _isopen; }
word getcurrentpage() { return _currentpage; } void setdate(TDate& d) { _date = d; }
void setcurrentpage(word n) { _currentpage = n; } TPrtype printtype() { return _printertype; }
word rows() const { return _formlen-_headersize-_footersize; } void set_printtype(TPrtype dest) { _printertype=dest; }
word rows_left() const; void set_printerfile(const char * ffile) { _printerfile=ffile; }
#if XVT_OS == XVT_OS_WIN word getcurrentpage() { return _currentpage; }
PRINT_RCD* get_printrcd() { return _print_rcd; } void setcurrentpage(word n) { _currentpage = n; }
void set_printrcd(PRINT_RCD* p) { _print_rcd = p; } word rows() const { return _formlen-_headersize-_footersize; }
int& get_printrcdsize() { return _print_rcd_size; } word rows_left() const;
void set_win_formlen(); #if XVT_OS == XVT_OS_WIN
#endif PRINT_RCD* get_printrcd() { return _print_rcd; }
void set_lines_per_inch(int n) { _lines_per_inch = n; } void set_printrcd(PRINT_RCD* p) { _print_rcd = p; }
int get_lines_per_inch(int n) { return _lines_per_inch; } int& get_printrcdsize() { return _print_rcd_size; }
int get_vert_offset() { return _vert_offset; } void set_win_formlen();
int get_horz_offset() { return _horz_offset; } #endif
int get_dots_per_line() { return _dots_per_line; } void set_lines_per_inch(int n) { _lines_per_inch = n; }
bool isgraphics() { return _isgraphics; } int get_lines_per_inch(int n) { return _lines_per_inch; }
int get_char_size() { return _ch_size; } int get_vert_offset() { return _vert_offset; }
}; int get_horz_offset() { return _horz_offset; }
int get_dots_per_line() { return _dots_per_line; }
bool isgraphics() { return _isgraphics; }
int get_char_size() { return _ch_size; }
class TFile_printer : public TPrinter };
{
long _size;
const char * _drive;
int _volume; // numero progressivo volume class TFile_printer : public TPrinter
int _num_rec_volume; // numero di record per disco {
int _num_rec_testa_coda; // numero di record per inizio e fine volume long _size;
int _num_rec_inizio; // numero di record per inizio volume const char * _drive;
int _num_rec_fine; // numero di record per coda volume int _volume; // numero progressivo volume
int _len_rec; // lunghezza record int _num_rec_volume; // numero di record per disco
TArray _record; // array di tipi record int _num_rec_testa_coda; // numero di record per inizio e fine volume
bool _nome_file_fissato; // se il file sui dischetti deve avere un nome NON modificabile dall'utente int _num_rec_inizio; // numero di record per inizio volume
bool _label_fissata; // se l'etichetta dei dischetti deve essere fissa int _num_rec_fine; // numero di record per coda volume
bool _formatta; int _len_rec; // lunghezza record
const char * _file; // file da generare sui dischetti TArray _record; // array di tipi record
const char * _label; // etichetta da scrivere sui dischetti bool _nome_file_fissato; // se il file sui dischetti deve avere un nome NON modificabile dall'utente
TArray _tmp_files; // array dei file temporanei generati bool _label_fissata; // se l'etichetta dei dischetti deve essere fissa
FILE * _fd; bool _formatta;
const char * _file; // file da generare sui dischetti
// bool scrivi_volume(); const char * _label; // etichetta da scrivere sui dischetti
TArray _tmp_files; // array dei file temporanei generati
public: FILE * _fd;
virtual char newline() { return '\0'; } // bool scrivi_volume();
void set_file_fissato (bool fissato) { _nome_file_fissato = fissato; }
void set_label_fissata (bool fissata) { _label_fissata = fissata; } public:
void set_len_rec (int len) { _len_rec = len; }
virtual char newline() { return '\0'; }
void set_file (const char * ffile) { _file = ffile; } void set_file_fissato (bool fissato) { _nome_file_fissato = fissato; }
void set_label (const char * label) { _label = label; } void set_label_fissata (bool fissata) { _label_fissata = fissata; }
void set_len_rec (int len) { _len_rec = len; }
void set_record (int record_to_set, TPrintrow* line)
{_record.add(line, record_to_set); } void set_file (const char * ffile) { _file = ffile; }
void set_label (const char * label) { _label = label; }
TPrintrow * get_record (int record_to_get)
{return (TPrintrow *)&_record[record_to_get]; } void set_record (int record_to_set, TPrintrow* line)
{_record.add(line, record_to_set); }
TPrintrow* get_record_inizio_volume() const { return (TPrintrow*)&_record[0];}
TPrintrow* get_record_inizio_elenco() const {return (TPrintrow*)&_record[1];} TPrintrow * get_record (int record_to_get)
TPrintrow* get_record_dettaglio() const { return (TPrintrow*)&_record[2]; } {return (TPrintrow *)&_record[record_to_get]; }
TPrintrow* get_record_fine_elenco() const {return (TPrintrow*)&_record[3]; }
TPrintrow* get_record_fine_volume() const { return (TPrintrow*)&_record[4]; } TPrintrow* get_record_inizio_volume() const { return (TPrintrow*)&_record[0];}
TPrintrow* get_record_filler() const { return (TPrintrow*)&_record[5]; } TPrintrow* get_record_inizio_elenco() const {return (TPrintrow*)&_record[1];}
TPrintrow* get_record_dettaglio() const { return (TPrintrow*)&_record[2]; }
int num_rec_volume () { return _num_rec_volume; } TPrintrow* get_record_fine_elenco() const {return (TPrintrow*)&_record[3]; }
int num_volumi () { return _volume; } TPrintrow* get_record_fine_volume() const { return (TPrintrow*)&_record[4]; }
void inc_volume () { _volume++; } TPrintrow* get_record_filler() const { return (TPrintrow*)&_record[5]; }
void add_file (TFilename nomef) { _tmp_files.add(nomef); } int num_rec_volume () { return _num_rec_volume; }
int num_volumi () { return _volume; }
void open(); void inc_volume () { _volume++; }
void close();
void add_file (TFilename nomef) { _tmp_files.add(nomef); }
// void scrivi();
bool genera_dischetti(); void open();
void close();
virtual void set ();
// void scrivi();
// bool genera_dischetti();
// tipo_disco:
// 0 per 360 virtual void set ();
// 1 per 1.2
// 2 per 720 //
// 3 per 1,44 // tipo_disco:
// 4 per 2,88 // 0 per 360
// // 1 per 1.2
TFile_printer (const char* file, // 2 per 720
const char* label, // 3 per 1,44
int len_rec, // 4 per 2,88
int num_rec_inizio = 1, //
int num_rec_fine = 1, int tipo_disco=0); TFile_printer (const char* file,
const char* label,
virtual ~TFile_printer(); int len_rec,
}; int num_rec_inizio = 1,
int num_rec_fine = 1, int tipo_disco=0);
#endif // __PRINTER_H
virtual ~TFile_printer();
};
#endif // __PRINTER_H

View File

@ -1,36 +1,36 @@
BUTTON DLG_SAVEREC 8 2 BUTTON DLG_SAVEREC 8 2
BEGIN BEGIN
PROMPT -16 -1 "~Registra" PROMPT -16 -1 "~Registra"
MESSAGE EXIT,K_SAVE MESSAGE EXIT,K_SAVE
END END
BUTTON DLG_NEWREC 8 2 BUTTON DLG_NEWREC 8 2
BEGIN BEGIN
PROMPT -26 -1 "~Nuovo" PROMPT -26 -1 "~Nuovo"
MESSAGE EXIT,K_INS MESSAGE EXIT,K_INS
END END
BUTTON DLG_DELREC 8 2 BUTTON DLG_DELREC 8 2
BEGIN BEGIN
PROMPT -36 -1 "~Elimina" PROMPT -36 -1 "~Elimina"
MESSAGE EXIT,K_DEL MESSAGE EXIT,K_DEL
END END
BUTTON DLG_FINDREC 8 2 BUTTON DLG_FINDREC 8 2
BEGIN BEGIN
PROMPT -46 -1 "Ri~cerca" PROMPT -46 -1 "Ri~cerca"
MESSAGE EXIT,K_F9 MESSAGE EXIT,K_F9
END END
BUTTON DLG_CANCEL 8 2 BUTTON DLG_CANCEL 8 2
BEGIN BEGIN
PROMPT -56 -1 "" PROMPT -56 -1 ""
MESSAGE EXIT,K_ESC MESSAGE EXIT,K_ESC
END END
BUTTON DLG_QUIT 8 2 BUTTON DLG_QUIT 8 2
BEGIN BEGIN
PROMPT -66 -1 "" PROMPT -66 -1 ""
MESSAGE EXIT,K_QUIT MESSAGE EXIT,K_QUIT
END END