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:
parent
c1e97ca1f9
commit
7c792335de
@ -1,94 +1,94 @@
|
||||
#ifndef __APPLICATION_H
|
||||
#define __APPLICATION_H
|
||||
|
||||
#ifndef INCL_XVTH
|
||||
#include <xvt.h>
|
||||
#endif
|
||||
|
||||
#ifndef __PRINTER_H
|
||||
#include <printer.h>
|
||||
#endif
|
||||
|
||||
#ifndef __MODAUT_H
|
||||
//#include <modaut.h>
|
||||
#endif
|
||||
|
||||
// @C
|
||||
// Classe TApplication
|
||||
// @END
|
||||
|
||||
#define MSG_AI "AI" // message auto_insert (relapp)
|
||||
#define MSG_FS "FS" // message filtered start (relapp)
|
||||
#define MSG_LN "LN" // message (printapp -> relapp)
|
||||
|
||||
class TApplication
|
||||
{
|
||||
// @DPRIV
|
||||
int _bar;
|
||||
int __argc;
|
||||
const char** __argv;
|
||||
|
||||
TString80 _name, _title;
|
||||
TPrinter* _printer;
|
||||
|
||||
protected:
|
||||
const char* get_module_name() const;
|
||||
static long task_eh(WINDOW win, EVENT* ep);
|
||||
|
||||
virtual long handler(WINDOW win, EVENT* ep);
|
||||
virtual bool extended_firm() const { return FALSE; } // Extended set_firm dialog box?
|
||||
|
||||
void terminate();
|
||||
bool config();
|
||||
void about() const;
|
||||
|
||||
public:
|
||||
// @FPUB
|
||||
|
||||
void setbar(int menubar) { _bar = menubar;} // Modifica la menu-bar
|
||||
void run(int argc, char* argv[], const char* name);
|
||||
|
||||
// @DES Queste funzioni possono essere ridefinite da ogni applicazione
|
||||
// @FPUB
|
||||
virtual bool create(); // Crea la finestra principale
|
||||
virtual bool menu(MENU_TAG) { return TRUE; } // Controlla il menu
|
||||
virtual bool destroy(); // Rimuove l'applicazione
|
||||
virtual void print();
|
||||
virtual word class_id() const { return CLASS_APPLICATION; }
|
||||
void stop_run(); // Forza chiusura applicazione
|
||||
|
||||
void check_menu_item(MENU_TAG item); // Check menu
|
||||
void uncheck_menu_item(MENU_TAG item); // Uncheck
|
||||
void enable_menu_item(MENU_TAG item, bool on = TRUE);
|
||||
void disable_menu_item(MENU_TAG item) { enable_menu_item(item, FALSE); }
|
||||
void dispatch_e_menu(MENU_TAG item);
|
||||
|
||||
const TString& name() const { return _name; }
|
||||
const char** argv() const { return __argv; }
|
||||
const char* argv(int i) const { return __argv[i]; }
|
||||
int argc() const { return __argc; }
|
||||
|
||||
void set_title(const char* t) { _title = t; }
|
||||
const char* title() const { return _title; }
|
||||
|
||||
void wait_for(const char* name);
|
||||
void wake_up_caller() const;
|
||||
|
||||
TPrinter* set_printer(TPrinter* p);
|
||||
TPrinter& printer();
|
||||
|
||||
virtual bool change_config(const char* var, const char* oldv, const char* newv);
|
||||
|
||||
bool has_module(int module) const;
|
||||
bool set_firm(long cod = -1);
|
||||
long get_firm() const;
|
||||
const char* get_firm_dir() const;
|
||||
|
||||
TApplication();
|
||||
virtual ~TApplication();
|
||||
};
|
||||
|
||||
bool xvt_running(); // xvt is running?
|
||||
TApplication* MainApp(); // main application
|
||||
|
||||
#endif // __APPLICATION_H
|
||||
#ifndef __APPLICATION_H
|
||||
#define __APPLICATION_H
|
||||
|
||||
#ifndef INCL_XVTH
|
||||
#include <xvt.h>
|
||||
#endif
|
||||
|
||||
#ifndef __PRINTER_H
|
||||
#include <printer.h>
|
||||
#endif
|
||||
|
||||
#ifndef __MODAUT_H
|
||||
//#include <modaut.h>
|
||||
#endif
|
||||
|
||||
// @C
|
||||
// Classe TApplication
|
||||
// @END
|
||||
|
||||
#define MSG_AI "AI" // message auto_insert (relapp)
|
||||
#define MSG_FS "FS" // message filtered start (relapp)
|
||||
#define MSG_LN "LN" // message (printapp -> relapp)
|
||||
|
||||
class TApplication
|
||||
{
|
||||
// @DPRIV
|
||||
int _bar;
|
||||
int __argc;
|
||||
const char** __argv;
|
||||
|
||||
TString80 _name, _title;
|
||||
TPrinter* _printer;
|
||||
|
||||
protected:
|
||||
const char* get_module_name() const;
|
||||
static long task_eh(WINDOW win, EVENT* ep);
|
||||
|
||||
virtual long handler(WINDOW win, EVENT* ep);
|
||||
virtual bool extended_firm() const { return FALSE; } // Extended set_firm dialog box?
|
||||
|
||||
void terminate();
|
||||
bool config();
|
||||
void about() const;
|
||||
|
||||
public:
|
||||
// @FPUB
|
||||
|
||||
void setbar(int menubar) { _bar = menubar;} // Modifica la menu-bar
|
||||
void run(int argc, char* argv[], const char* name);
|
||||
|
||||
// @DES Queste funzioni possono essere ridefinite da ogni applicazione
|
||||
// @FPUB
|
||||
virtual bool create(); // Crea la finestra principale
|
||||
virtual bool menu(MENU_TAG) { return TRUE; } // Controlla il menu
|
||||
virtual bool destroy(); // Rimuove l'applicazione
|
||||
virtual void print();
|
||||
virtual word class_id() const { return CLASS_APPLICATION; }
|
||||
void stop_run(); // Forza chiusura applicazione
|
||||
|
||||
void check_menu_item(MENU_TAG item); // Check menu
|
||||
void uncheck_menu_item(MENU_TAG item); // Uncheck
|
||||
void enable_menu_item(MENU_TAG item, bool on = TRUE);
|
||||
void disable_menu_item(MENU_TAG item) { enable_menu_item(item, FALSE); }
|
||||
void dispatch_e_menu(MENU_TAG item);
|
||||
|
||||
const TString& name() const { return _name; }
|
||||
const char** argv() const { return __argv; }
|
||||
const char* argv(int i) const { return __argv[i]; }
|
||||
int argc() const { return __argc; }
|
||||
|
||||
void set_title(const char* t) { _title = t; }
|
||||
const char* title() const { return _title; }
|
||||
|
||||
void wait_for(const char* name);
|
||||
void wake_up_caller() const;
|
||||
|
||||
TPrinter* set_printer(TPrinter* p);
|
||||
TPrinter& printer();
|
||||
|
||||
virtual bool change_config(const char* var, const char* oldv, const char* newv);
|
||||
|
||||
bool has_module(int module) const;
|
||||
bool set_firm(long cod = -1);
|
||||
long get_firm() const;
|
||||
const char* get_firm_dir() const;
|
||||
|
||||
TApplication();
|
||||
virtual ~TApplication();
|
||||
};
|
||||
|
||||
bool xvt_running(); // xvt is running?
|
||||
TApplication* MainApp(); // main application
|
||||
|
||||
#endif // __APPLICATION_H
|
||||
|
@ -1,39 +1,39 @@
|
||||
#ifndef __CLASSES_H
|
||||
#define __CLASSES_H
|
||||
|
||||
// @N
|
||||
// Codici identificativi delle classi
|
||||
// @END
|
||||
|
||||
// @M
|
||||
#define CLASS_OBJECT 1
|
||||
#define CLASS_ERROR 0
|
||||
#define CLASS_SORTABLE 2
|
||||
|
||||
#define CLASS_STRING 10
|
||||
#define CLASS_FIXED_STRING 11
|
||||
#define CLASS_FILENAME 12
|
||||
#define CLASS_TOKEN_STRING 13
|
||||
|
||||
#define CLASS_APPLICATION 40
|
||||
#define CLASS_PRINT_APPLICATION 41
|
||||
|
||||
#define CLASS_PRINTROW 50
|
||||
#define CLASS_PRINTER 51
|
||||
|
||||
#define CLASS_CONTAINER 100
|
||||
#define CLASS_ARRAY 101
|
||||
#define CLASS_STACK 102
|
||||
|
||||
#define CLASS_FIELD 20
|
||||
#define CLASS_EDIT_FIELD 21
|
||||
#define CLASS_REAL_FIELD 22
|
||||
#define CLASS_DATE_FIELD 23
|
||||
#define CLASS_BOOLEAN_FIELD 30
|
||||
#define CLASS_LIST_FIELD 31
|
||||
#define CLASS_RADIO_FIELD 32
|
||||
#define CLASS_BUTTON_FIELD 40
|
||||
#define CLASS_SHEET_FIELD 50
|
||||
|
||||
// @END
|
||||
#endif // __CLASSES_H
|
||||
#ifndef __CLASSES_H
|
||||
#define __CLASSES_H
|
||||
|
||||
// @N
|
||||
// Codici identificativi delle classi
|
||||
// @END
|
||||
|
||||
// @M
|
||||
#define CLASS_OBJECT 1
|
||||
#define CLASS_ERROR 0
|
||||
#define CLASS_SORTABLE 2
|
||||
|
||||
#define CLASS_STRING 10
|
||||
#define CLASS_FIXED_STRING 11
|
||||
#define CLASS_FILENAME 12
|
||||
#define CLASS_TOKEN_STRING 13
|
||||
|
||||
#define CLASS_APPLICATION 40
|
||||
#define CLASS_PRINT_APPLICATION 41
|
||||
|
||||
#define CLASS_PRINTROW 50
|
||||
#define CLASS_PRINTER 51
|
||||
|
||||
#define CLASS_CONTAINER 100
|
||||
#define CLASS_ARRAY 101
|
||||
#define CLASS_STACK 102
|
||||
|
||||
#define CLASS_FIELD 20
|
||||
#define CLASS_EDIT_FIELD 21
|
||||
#define CLASS_REAL_FIELD 22
|
||||
#define CLASS_DATE_FIELD 23
|
||||
#define CLASS_BOOLEAN_FIELD 30
|
||||
#define CLASS_LIST_FIELD 31
|
||||
#define CLASS_RADIO_FIELD 32
|
||||
#define CLASS_BUTTON_FIELD 40
|
||||
#define CLASS_SHEET_FIELD 50
|
||||
|
||||
// @END
|
||||
#endif // __CLASSES_H
|
||||
|
@ -1,30 +1,30 @@
|
||||
#ifndef _FLD_MOV_H
|
||||
#define _FLD_MOV_H
|
||||
|
||||
#define MOV_ANNOES "ANNOES"
|
||||
#define MOV_ANNOIVA "ANNOIVA"
|
||||
#define MOV_NUMREG "NUMREG"
|
||||
#define MOV_DATAREG "DATAREG"
|
||||
#define MOV_TIPO "TIPO"
|
||||
#define MOV_CODCF "CODCF"
|
||||
#define MOV_DATADOC "DATADOC"
|
||||
#define MOV_NUMDOC "NUMDOC"
|
||||
#define MOV_TIPODOC "TIPODOC"
|
||||
#define MOV_TOTDOC "TOTDOC"
|
||||
#define MOV_CODCAUS "CODCAUS"
|
||||
#define MOV_DESCR "DESCR"
|
||||
#define MOV_TIPOMOV "TIPOMOV"
|
||||
#define MOV_REG "REG"
|
||||
#define MOV_PROTIVA "PROTIVA"
|
||||
#define MOV_UPROTIVA "UPROTIVA"
|
||||
#define MOV_CODVAL "CODVAL"
|
||||
#define MOV_CAMBIO "CAMBIO"
|
||||
#define MOV_STAMPATO "STAMPATO"
|
||||
#define MOV_NUMGIO "NUMGIO"
|
||||
#define MOV_PROVVIS "PROVVIS"
|
||||
#define MOV_OCFPI "OCFPI"
|
||||
#define MOV_CORRLIRE "CORRLIRE"
|
||||
#define MOV_CORRVALUTA "CORRVALUTA"
|
||||
#define MOV_DATACOMP "DATACOMP"
|
||||
|
||||
#endif
|
||||
#ifndef _FLD_MOV_H
|
||||
#define _FLD_MOV_H
|
||||
|
||||
#define MOV_ANNOES "ANNOES"
|
||||
#define MOV_ANNOIVA "ANNOIVA"
|
||||
#define MOV_NUMREG "NUMREG"
|
||||
#define MOV_DATAREG "DATAREG"
|
||||
#define MOV_TIPO "TIPO"
|
||||
#define MOV_CODCF "CODCF"
|
||||
#define MOV_DATADOC "DATADOC"
|
||||
#define MOV_NUMDOC "NUMDOC"
|
||||
#define MOV_TIPODOC "TIPODOC"
|
||||
#define MOV_TOTDOC "TOTDOC"
|
||||
#define MOV_CODCAUS "CODCAUS"
|
||||
#define MOV_DESCR "DESCR"
|
||||
#define MOV_TIPOMOV "TIPOMOV"
|
||||
#define MOV_REG "REG"
|
||||
#define MOV_PROTIVA "PROTIVA"
|
||||
#define MOV_UPROTIVA "UPROTIVA"
|
||||
#define MOV_CODVAL "CODVAL"
|
||||
#define MOV_CAMBIO "CAMBIO"
|
||||
#define MOV_STAMPATO "STAMPATO"
|
||||
#define MOV_NUMGIO "NUMGIO"
|
||||
#define MOV_PROVVIS "PROVVIS"
|
||||
#define MOV_OCFPI "OCFPI"
|
||||
#define MOV_CORRLIRE "CORRLIRE"
|
||||
#define MOV_CORRVALUTA "CORRVALUTA"
|
||||
#define MOV_DATACOMP "DATACOMP"
|
||||
|
||||
#endif
|
||||
|
@ -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 <stdarg.h>
|
||||
|
||||
@ -762,10 +762,11 @@ void TPrint_application::print()
|
||||
|
||||
// only external apps can change it
|
||||
_repeat_print = FALSE;
|
||||
ncopies = printer().n_copies();
|
||||
|
||||
// never print multiple copies if printer is viswin
|
||||
// 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
|
||||
// pre and post process do everything
|
||||
@ -1242,7 +1243,6 @@ TPrint_application::TPrint_application ():TApplication (), _transtab (10),
|
||||
{
|
||||
_cur = NULL;
|
||||
_repeat_print = FALSE;
|
||||
_ncopies = 1;
|
||||
_currow = _maxrow = 0;
|
||||
_auto_ff = FALSE;
|
||||
_wbar = _wcancel = TRUE;
|
||||
|
@ -1,471 +1,468 @@
|
||||
// trattasi di -*-c++-*-
|
||||
#ifndef __PRINTAPP_H
|
||||
#define __PRINTAPP_H
|
||||
|
||||
#ifndef __APPLICATION_H
|
||||
#include <applicat.h>
|
||||
#endif
|
||||
|
||||
#ifndef __PRINTER_H
|
||||
#include <printer.h>
|
||||
#endif
|
||||
|
||||
#ifndef __RELATION_H
|
||||
#include <relation.h>
|
||||
#endif
|
||||
|
||||
// compatibility
|
||||
#define TPrintapp TPrint_application
|
||||
|
||||
|
||||
enum print_action { REPEAT_PAGE, NEXT_PAGE };
|
||||
|
||||
// user functions to pass field informations to setrow()
|
||||
// no class or nice C++ interface since varargs is nasty
|
||||
|
||||
// FLD(Num.logico, Nome campo [, da [, a]])
|
||||
const char* FLD(int lognum, const char* f, int from = -1, int to = -1);
|
||||
// FLD(Num. logico, Nome campo numerico, Picture string)
|
||||
const char* FLD(int lognum, const char* f, const char* picture);
|
||||
// FLD(Nome tabella, Nome campo numerico, Picture string)
|
||||
const char* FLD(const char* tabname, const char* f, const char* picture);
|
||||
// FLD(Num.logico, Nome campo [, da [, a]])
|
||||
const char* FLD(const char* tabname, const char* f, int from = -1, int to = -1);
|
||||
|
||||
struct link_item {
|
||||
int _logicnum;
|
||||
link_item* _son;
|
||||
link_item* _brother;
|
||||
int _cnt;
|
||||
|
||||
link_item(int l)
|
||||
{ _logicnum = l; _son = NULL; _brother = NULL; _cnt = 0; }
|
||||
};
|
||||
|
||||
class TProgind;
|
||||
|
||||
|
||||
class TPrint_application : public TApplication
|
||||
{
|
||||
TArray _rows; // rows descriptor
|
||||
TArray _cursors; // cursor array
|
||||
TCursor* _cur; // current cursor
|
||||
TArray _transtab; // field translation table
|
||||
TArray _header; // header lines
|
||||
TArray _footer; // footer lines
|
||||
int _currow; // current print row
|
||||
TPrintstyle _curstyle; // current print style
|
||||
bool _auto_ff; // automatic form feed after each page
|
||||
const char* _wmess; // wait message for progind
|
||||
bool _wbar; // bar y/n for progind
|
||||
bool _wcancel; // cancel button enabled
|
||||
int _wthr; // minimum # of items to show print progind
|
||||
const char* _confpr; // config filename for printer
|
||||
char _fillchar; // fill character for empty fields
|
||||
link_item* _pr_tree; // functions for autom. printing of relations
|
||||
int _maxrow; // reference to maxrow
|
||||
int _cur_file;
|
||||
bool _print_defined;
|
||||
bool _force_progind;
|
||||
bool _force_setpage;
|
||||
bool _print_zero;
|
||||
TProgind* _prind;
|
||||
const char* _picture;
|
||||
MENU_TAG _last_choice;
|
||||
int _ncopies;
|
||||
bool _repeat_print;
|
||||
|
||||
// set the printer
|
||||
void set_printer() { printer().set(); }
|
||||
// print a single record; does not advance cursor
|
||||
// returns failure or success
|
||||
bool print_one(int file);
|
||||
// to be documented but very fig
|
||||
bool print_tree(link_item* head);
|
||||
|
||||
static void _pp_header(TPrinter& pr);
|
||||
static void _pp_footer(TPrinter& pr);
|
||||
static void _pp_link(int id, const char* s);
|
||||
|
||||
link_item* _look_print_node(link_item* head, int logicnum);
|
||||
void _reset_tree(link_item* head);
|
||||
virtual bool create();
|
||||
virtual bool destroy();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// ****************************************************
|
||||
// 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:
|
||||
//
|
||||
// 1) Derivare una classe da TPrint_application
|
||||
// 2) Implementare user_create() e user_destroy();
|
||||
// Nella user_create() si creino i
|
||||
// necessari cursori, e li si dia in pasto a Printapp
|
||||
// usando add_cursor(). Si puo' fare add_cursor(new TCursor(...))
|
||||
// dato che il cursore viene distrutto automaticamente.
|
||||
// 3) Per ciascun file del cursore che si desidera porre
|
||||
// nell'albero di stampa, si faccia add_file(logicnum [,from]);
|
||||
// [from] sara' il file a cui e' collegato nella relazione.
|
||||
// add_file VA FATTA anche per il file principale, se no
|
||||
// non stampera' nulla;
|
||||
// *********************************************************
|
||||
// FUNZIONI VIRTUALI OBBLIGATORIE
|
||||
// *********************************************************
|
||||
// 4) Si definiscono le necessarie funzioni virtuali: e'
|
||||
// sicuramente necessaria la set_page(file) nella quale
|
||||
// si metteranno (sotto if o switch) le istruzioni
|
||||
// set_row (vedi sotto) corrispondenti alla pagina
|
||||
// logica relativa a ciascun record di ogni file da stampare.
|
||||
// Va definita anche set_print() in cui si presentera' ;a
|
||||
// maschera di scelta se necessaria o una box yes_no;
|
||||
// Ritornando TRUE da set_print la stampa viene eseguita
|
||||
// automaticamente (in genere ritorna FALSE se l'utente
|
||||
// annulla la stampa con ESC.)
|
||||
//
|
||||
// Alla set_page, come alle pre_ e post_ process, viene
|
||||
// passato 0 se il cursore attuale e' nullo (vedi sotto).
|
||||
// *********************************************************
|
||||
// FUNZIONI VIRTUALI FACOLTATIVE
|
||||
// *********************************************************
|
||||
// 5) Le varie funzioni pre_ e post_ process _page e _print
|
||||
// vengono chiamate prima e dopo la stampa di ogni record
|
||||
// o gruppo di record relativo alla relazione immessa;
|
||||
// ad esempio, postprocess_print() viene chiamata per il
|
||||
// file principale una volta dopo l'intera stampa; per
|
||||
// un file collegato nella relazione, e' chiamata tante
|
||||
// volte quanti gruppi di almeno un record esistono per
|
||||
// record del file genitore. Qui si possono modificare
|
||||
// righe, calcolare totali etc. A queste funzioni
|
||||
// viene sempre passato il file (logicnum) in corso di stampa e
|
||||
// un contatore che indica quante volte la stampa e' stata
|
||||
// ripetuta. le pre_ ritornano TRUE o FALSE, nell'ultimo
|
||||
// caso interrompono la stampa; le post_ ritornano
|
||||
// NEXT_PAGE (comportamento normale) o REPEAT_PAGE
|
||||
// (indovina cosa fa).
|
||||
// 6) set_print() viene chiamata dalla voce Selezione,
|
||||
// unica del secondo menu. E' il posto dove mettere
|
||||
// una buona maschera di selezione di cosa stampare.
|
||||
// Alla fine, si esegua enable_print_menu() per
|
||||
// abilitare la voce Stampa, inizialmente inattiva.
|
||||
// 7) cancel_hook() permette di intercettare la
|
||||
// cancellazione della stampa; ritornando TRUE
|
||||
// la stampa viene effettivamente cancellata
|
||||
// Tutti i parametri relativi al progress indicator
|
||||
// vengono settati da funzioni apposite (vedi oltre)
|
||||
// ****************************************************
|
||||
// Molte altre minchiatine (form feed automatici, header,
|
||||
// footer etc) sono spiegate nel seguito
|
||||
// ****************************************************
|
||||
|
||||
virtual void user_create() {}
|
||||
virtual void user_destroy() {}
|
||||
|
||||
// set print, bound to menu :Selezione:Stampa
|
||||
// chiamata automaticamente dopo user_create()
|
||||
virtual bool set_print(int i = 1) { return FALSE; }
|
||||
|
||||
// set_row functions MUST be called here in a switch
|
||||
// for each particular file being printed
|
||||
virtual void set_page(int file, int cnt) {}
|
||||
|
||||
// called before processing each page
|
||||
// used to set print strings from tables or files
|
||||
// not included in relation
|
||||
// returning FALSE cancels page printing
|
||||
// counter is the current print page number
|
||||
virtual bool preprocess_page(int file, int counter)
|
||||
{ return TRUE; }
|
||||
|
||||
// same before each print request
|
||||
// e.g. to initialize counters
|
||||
// returning FALSE cancels print request or subtree
|
||||
virtual bool preprocess_print(int file, int counter)
|
||||
{ return TRUE; }
|
||||
|
||||
// postprocessing; returning REPEAT_PAGE reprints the
|
||||
// whole page (after all sons are printed) or print
|
||||
// counter is the current page or print number
|
||||
virtual print_action postprocess_page(int file, int counter)
|
||||
{ return NEXT_PAGE; }
|
||||
virtual print_action postprocess_print(int file, int counter)
|
||||
{ return NEXT_PAGE; }
|
||||
// executed after all print job is completed
|
||||
virtual void postclose_print() {}
|
||||
|
||||
// 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;}
|
||||
|
||||
// bound to TApplication print menu
|
||||
// redefined ONLY for very special purposes
|
||||
virtual void print();
|
||||
|
||||
// bound to <select> menu and automatically called after
|
||||
// user_create()
|
||||
void do_print(int n);
|
||||
|
||||
public:
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// COME SETTARE LE RIGHE DI STAMPA
|
||||
// --------------------------------------------------------------
|
||||
// setrow() si usa come una printf per settare le righe di stampa
|
||||
// che vengono stampate da print()
|
||||
// I codici per gli argomenti variabili sono di 3 tipi:
|
||||
// @ si usa per stampare campi di database o informazioni di controllo
|
||||
// posizione carrello e font
|
||||
// ACHTUNG: i codici di formato sono diversi da quelli di printf e
|
||||
// sono elencati sotto. Per i campi di database occorre che il codice
|
||||
// sia accoppiato ad una delle funzioni FLD() passata come argomento;
|
||||
// questa provoca la stampa di campi della relazione corrente,
|
||||
// posizionata come e' stato deciso nell'inizializzazione
|
||||
// % 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
|
||||
// ignorato il carattere di riempimento eventualmente specificato
|
||||
// con set_fillchar. Cio' vale anche per i codici @ (vedi)
|
||||
// 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
|
||||
// viene interpretato con le stesse regole di %t in dsprintf per real
|
||||
// (come %d o %f) e di %s per TString. Il puntatore NON
|
||||
// viene memorizzato; per questo occorre il codice # (sotto).
|
||||
// # si usa come % (stessi codici di printf) ma memorizza gli argomenti
|
||||
// per riferimento: ovvero, ogni volta che la riga viene stampata
|
||||
// viene stampato il contenuto in quel momento (che si puo' cambiare
|
||||
// in una delle pre- o post- process). Cio' implica che:
|
||||
// 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
|
||||
// la fine della stampa
|
||||
// Quindi, attenzione a %s con TString ridimensionate; si possono
|
||||
// usare solo se predimensionate alla dimensione massima, ma e' meglio
|
||||
// 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.
|
||||
// Comunque, il modo corretto di adoperare il codice # e'
|
||||
// usarlo solo per stampare MEMBRI della classe derivata da TPrint_application
|
||||
// ----------------------------------------------
|
||||
// field codes (match one of FLD() functions)
|
||||
// @@ -> @
|
||||
// @[n[,{l|c|r}]s -> STRING: n = pad, lcr = alignment
|
||||
// @{[n[.d=0]]|[n[,{l|c|r}]]p}n
|
||||
// -> NUMBER: n = digits, d = decimals
|
||||
// p = picture string (first matching arg)
|
||||
// @[l]d -> DATE: l = full year
|
||||
// @f -> BOOL: prints si/no
|
||||
// @[n,{l|c|r}]t -> Translated field (must set translation)
|
||||
//
|
||||
// Tutti questi codici possono essere usati anche maiuscoli, il che inibisce
|
||||
// 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)
|
||||
// se non vengono date ulteriori specifiche di formato viene usata
|
||||
// una picture che e' "" per default, ma puo' essere modificata con
|
||||
// set_real_picture(). Anche questo e' assai carino.
|
||||
// Normalmente un real uguale a zero viene stampato come stringa vuota
|
||||
// a meno che non si specifichi set_print_zero([TRUE]).
|
||||
// ---------------------------------------------
|
||||
// codici posizionamento e movimento carrello
|
||||
// @<n>g vai a posizione n
|
||||
// @<n>j salta di n posizioni (in orizzontale)
|
||||
// codici stile
|
||||
// @b bold
|
||||
// @i italic
|
||||
// @u underlined
|
||||
// @r reset to normal
|
||||
// ---------------------------------------------------
|
||||
// CODICI COLORE PER VISUALIZZAZIONE E COLLEGAMENTO
|
||||
// ---------------------------------------------------
|
||||
// Se si vuole che in visualizzazione il testo sia colorato
|
||||
// si usa il codice $[]; tra le quadre si scrive il colore
|
||||
// di foreground, opzionalmente seguito da una virgola e dal
|
||||
// colore di background (bianco per default). I colori si
|
||||
// specificano con un singolo carattere come segue:
|
||||
// n nero
|
||||
// g verde
|
||||
// b blu
|
||||
// c cyan
|
||||
// y giallo
|
||||
// v magenta
|
||||
// m colore background maschere (azzurrotto)
|
||||
// d grigio scuro
|
||||
// l grigio chiaro
|
||||
// k grigio normale
|
||||
// ------------------------------------------------------
|
||||
// Se si fa enable_link(..) con un certo colore, tutto
|
||||
// cio; che e' scritto in quel colore diventa selezionabile
|
||||
// e alla sua selezione (premendo 'Collega') si puo' associare
|
||||
// un'azione in process_link. A quest'ultima viene passata
|
||||
// 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
|
||||
// rilettura di set_page() alla prossima volta
|
||||
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")
|
||||
// provoca la stampa automatica di stringhe al
|
||||
// posto di determinati valori dei campi se e' dato
|
||||
// il codice @t
|
||||
// Il posto giusto per chiamarla: user_create()
|
||||
// ---------------------------------------------
|
||||
void set_translation(int lognum, const char* field,
|
||||
const char* from, const char* to);
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// hypertext interface for viswin
|
||||
// --------------------------------------------------------
|
||||
// Quando si vogliono abilitare determinati colori come
|
||||
// indicatori di legame ipertestuale, si faccia enable_link
|
||||
// nella create. L' ID ritornato viene passato a process_link
|
||||
// assieme al testo selezionato
|
||||
int enable_link (const char* descr, char fg, char bg = 'w');
|
||||
void disable_link(char fg, char bg = 'w');
|
||||
void disable_links() { printer().links().destroy(); }
|
||||
// se si setta multiple a TRUE anziche' la descrizione del testo selezionato
|
||||
// viene passata a enable_link una tokenstring con tutte i 'bottoni' dello
|
||||
// stesso colore presenti sulla riga
|
||||
void set_multiple_link(bool on);
|
||||
|
||||
|
||||
// BACKGROUND PAINTING! Chefigata! poi vi spiego....
|
||||
void set_background(const char* bgdesc = NULL);
|
||||
|
||||
|
||||
// ---------------------------------------------
|
||||
// set/select cursor
|
||||
// ---------------------------------------------
|
||||
// selects i-th cursor
|
||||
// inutile se c'e' un cursore solo
|
||||
void select_cursor(int i);
|
||||
|
||||
// return i-th cursor without making it current
|
||||
TCursor* get_cursor(int i);
|
||||
// returns maximum row defined
|
||||
int get_maxrow() { return _maxrow; }
|
||||
|
||||
// adds cursor to class; return identifier
|
||||
// cursor* can be NULL: no file is used but
|
||||
// print_one is called and iterations are performed
|
||||
// by pre_ and post_ process
|
||||
int add_cursor(TCursor* c);
|
||||
|
||||
// retrieve current cursor
|
||||
TCursor* current_cursor() { return _cur; }
|
||||
|
||||
// ---------------------------------------------
|
||||
// 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)
|
||||
void set_auto_ff( bool b = TRUE)
|
||||
{ _auto_ff = b; }
|
||||
|
||||
// il carattere specificato con set_fillchar (default ' ') viene
|
||||
// usato per riempire davanti e dietro i campi in cui si e' specificata
|
||||
// una dimensione maggiore della lunghezza effettiva del contenuto,
|
||||
// (a meno che non si sia usato un codice di formato maiuscolo)
|
||||
void set_fillchar(char c)
|
||||
{ _fillchar = c; }
|
||||
|
||||
// riempie di righe vuote la pagina corrente fino alla dimensione
|
||||
// della pagina
|
||||
void fill_page(int from = -1);
|
||||
|
||||
// di solito basta e avanza quella di default
|
||||
virtual bool menu(MENU_TAG m);
|
||||
|
||||
virtual word class_id() const { return CLASS_PRINT_APPLICATION; }
|
||||
|
||||
// print menu is enabled when set_print returns TRUE
|
||||
void enable_print_menu();
|
||||
void disable_print_menu();
|
||||
void enable_setprint_menu();
|
||||
void disable_setprint_menu();
|
||||
|
||||
// header/footer (printf, not set_row analogues)
|
||||
// only understand @-codes for setting font attributes,
|
||||
// date and page number
|
||||
// plus every printf %-code
|
||||
|
||||
// con queste si possono ridefinire header e footer al
|
||||
// verificarsi di condizioni durante la stampa
|
||||
virtual void preprocess_header() {}
|
||||
virtual void preprocess_footer() {}
|
||||
|
||||
void set_header(int row, const char* fmt, ...);
|
||||
void set_footer(int row, const char* fmt, ...);
|
||||
void reset_header();
|
||||
void reset_footer();
|
||||
|
||||
// vedi sopra per capire
|
||||
void reset_files() { _reset_tree(_pr_tree); _pr_tree = NULL; }
|
||||
void add_file(int file, int from = 0);
|
||||
void add_file(const char* tab, int from = 0);
|
||||
|
||||
// set default picture for reals
|
||||
void set_real_picture(const char* p) { _picture = p; }
|
||||
void set_print_zero(bool b = TRUE) { _print_zero = b; }
|
||||
|
||||
// progress indicator control
|
||||
void set_wait_message(const char* m)
|
||||
{ _wmess = m; }
|
||||
void set_wait_bar(bool m)
|
||||
// default yes
|
||||
{ _wbar = m; }
|
||||
void set_wait_cancel(bool m)
|
||||
// default yes
|
||||
{ _wcancel = m; }
|
||||
void set_wait_threshold(int m)
|
||||
// minimum number of print items to show progress indicator;
|
||||
// default 2
|
||||
{ _wthr = m; }
|
||||
|
||||
// questa forza la progind anche se si stampa su video
|
||||
void force_progind(bool b = TRUE)
|
||||
{ _force_progind = b; }
|
||||
|
||||
// questa forza la rilettura delle setrow in set_page ad ogni
|
||||
// record stampato, in modo che i dati siano
|
||||
// sempre quelli del record corrente anche se si usano codici %
|
||||
// s'intende che rallenta un po' la stampa
|
||||
void force_setpage(bool b = TRUE)
|
||||
{ _force_setpage = b; }
|
||||
|
||||
void set_config_file(const char* s)
|
||||
{ _confpr = s; }
|
||||
word get_page_number()
|
||||
{ return printer().getcurrentpage(); }
|
||||
void set_page_number(word n)
|
||||
{ printer().setcurrentpage(n); }
|
||||
|
||||
|
||||
void set_n_copies(int n) { _ncopies = n; }
|
||||
int get_n_copies() { return _ncopies; }
|
||||
void repeat_print() { _repeat_print = TRUE; }
|
||||
|
||||
TPrint_application();
|
||||
virtual ~TPrint_application();
|
||||
};
|
||||
|
||||
// buon divertimento
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// trattasi di -*-c++-*-
|
||||
#ifndef __PRINTAPP_H
|
||||
#define __PRINTAPP_H
|
||||
|
||||
#ifndef __APPLICATION_H
|
||||
#include <applicat.h>
|
||||
#endif
|
||||
|
||||
#ifndef __PRINTER_H
|
||||
#include <printer.h>
|
||||
#endif
|
||||
|
||||
#ifndef __RELATION_H
|
||||
#include <relation.h>
|
||||
#endif
|
||||
|
||||
// compatibility
|
||||
#define TPrintapp TPrint_application
|
||||
|
||||
|
||||
enum print_action { REPEAT_PAGE, NEXT_PAGE };
|
||||
|
||||
// user functions to pass field informations to setrow()
|
||||
// no class or nice C++ interface since varargs is nasty
|
||||
|
||||
// FLD(Num.logico, Nome campo [, da [, a]])
|
||||
const char* FLD(int lognum, const char* f, int from = -1, int to = -1);
|
||||
// FLD(Num. logico, Nome campo numerico, Picture string)
|
||||
const char* FLD(int lognum, const char* f, const char* picture);
|
||||
// FLD(Nome tabella, Nome campo numerico, Picture string)
|
||||
const char* FLD(const char* tabname, const char* f, const char* picture);
|
||||
// FLD(Num.logico, Nome campo [, da [, a]])
|
||||
const char* FLD(const char* tabname, const char* f, int from = -1, int to = -1);
|
||||
|
||||
struct link_item {
|
||||
int _logicnum;
|
||||
link_item* _son;
|
||||
link_item* _brother;
|
||||
int _cnt;
|
||||
|
||||
link_item(int l)
|
||||
{ _logicnum = l; _son = NULL; _brother = NULL; _cnt = 0; }
|
||||
};
|
||||
|
||||
class TProgind;
|
||||
|
||||
|
||||
class TPrint_application : public TApplication
|
||||
{
|
||||
TArray _rows; // rows descriptor
|
||||
TArray _cursors; // cursor array
|
||||
TCursor* _cur; // current cursor
|
||||
TArray _transtab; // field translation table
|
||||
TArray _header; // header lines
|
||||
TArray _footer; // footer lines
|
||||
int _currow; // current print row
|
||||
TPrintstyle _curstyle; // current print style
|
||||
bool _auto_ff; // automatic form feed after each page
|
||||
const char* _wmess; // wait message for progind
|
||||
bool _wbar; // bar y/n for progind
|
||||
bool _wcancel; // cancel button enabled
|
||||
int _wthr; // minimum # of items to show print progind
|
||||
const char* _confpr; // config filename for printer
|
||||
char _fillchar; // fill character for empty fields
|
||||
link_item* _pr_tree; // functions for autom. printing of relations
|
||||
int _maxrow; // reference to maxrow
|
||||
int _cur_file;
|
||||
bool _print_defined;
|
||||
bool _force_progind;
|
||||
bool _force_setpage;
|
||||
bool _print_zero;
|
||||
TProgind* _prind;
|
||||
const char* _picture;
|
||||
MENU_TAG _last_choice;
|
||||
bool _repeat_print;
|
||||
|
||||
// set the printer
|
||||
void set_printer() { printer().set(); }
|
||||
// print a single record; does not advance cursor
|
||||
// returns failure or success
|
||||
bool print_one(int file);
|
||||
// to be documented but very fig
|
||||
bool print_tree(link_item* head);
|
||||
|
||||
static void _pp_header(TPrinter& pr);
|
||||
static void _pp_footer(TPrinter& pr);
|
||||
static void _pp_link(int id, const char* s);
|
||||
|
||||
link_item* _look_print_node(link_item* head, int logicnum);
|
||||
void _reset_tree(link_item* head);
|
||||
virtual bool create();
|
||||
virtual bool destroy();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// ****************************************************
|
||||
// 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:
|
||||
//
|
||||
// 1) Derivare una classe da TPrint_application
|
||||
// 2) Implementare user_create() e user_destroy();
|
||||
// Nella user_create() si creino i
|
||||
// necessari cursori, e li si dia in pasto a Printapp
|
||||
// usando add_cursor(). Si puo' fare add_cursor(new TCursor(...))
|
||||
// dato che il cursore viene distrutto automaticamente.
|
||||
// 3) Per ciascun file del cursore che si desidera porre
|
||||
// nell'albero di stampa, si faccia add_file(logicnum [,from]);
|
||||
// [from] sara' il file a cui e' collegato nella relazione.
|
||||
// add_file VA FATTA anche per il file principale, se no
|
||||
// non stampera' nulla;
|
||||
// *********************************************************
|
||||
// FUNZIONI VIRTUALI OBBLIGATORIE
|
||||
// *********************************************************
|
||||
// 4) Si definiscono le necessarie funzioni virtuali: e'
|
||||
// sicuramente necessaria la set_page(file) nella quale
|
||||
// si metteranno (sotto if o switch) le istruzioni
|
||||
// set_row (vedi sotto) corrispondenti alla pagina
|
||||
// logica relativa a ciascun record di ogni file da stampare.
|
||||
// Va definita anche set_print() in cui si presentera' ;a
|
||||
// maschera di scelta se necessaria o una box yes_no;
|
||||
// Ritornando TRUE da set_print la stampa viene eseguita
|
||||
// automaticamente (in genere ritorna FALSE se l'utente
|
||||
// annulla la stampa con ESC.)
|
||||
//
|
||||
// Alla set_page, come alle pre_ e post_ process, viene
|
||||
// passato 0 se il cursore attuale e' nullo (vedi sotto).
|
||||
// *********************************************************
|
||||
// FUNZIONI VIRTUALI FACOLTATIVE
|
||||
// *********************************************************
|
||||
// 5) Le varie funzioni pre_ e post_ process _page e _print
|
||||
// vengono chiamate prima e dopo la stampa di ogni record
|
||||
// o gruppo di record relativo alla relazione immessa;
|
||||
// ad esempio, postprocess_print() viene chiamata per il
|
||||
// file principale una volta dopo l'intera stampa; per
|
||||
// un file collegato nella relazione, e' chiamata tante
|
||||
// volte quanti gruppi di almeno un record esistono per
|
||||
// record del file genitore. Qui si possono modificare
|
||||
// righe, calcolare totali etc. A queste funzioni
|
||||
// viene sempre passato il file (logicnum) in corso di stampa e
|
||||
// un contatore che indica quante volte la stampa e' stata
|
||||
// ripetuta. le pre_ ritornano TRUE o FALSE, nell'ultimo
|
||||
// caso interrompono la stampa; le post_ ritornano
|
||||
// NEXT_PAGE (comportamento normale) o REPEAT_PAGE
|
||||
// (indovina cosa fa).
|
||||
// 6) set_print() viene chiamata dalla voce Selezione,
|
||||
// unica del secondo menu. E' il posto dove mettere
|
||||
// una buona maschera di selezione di cosa stampare.
|
||||
// Alla fine, si esegua enable_print_menu() per
|
||||
// abilitare la voce Stampa, inizialmente inattiva.
|
||||
// 7) cancel_hook() permette di intercettare la
|
||||
// cancellazione della stampa; ritornando TRUE
|
||||
// la stampa viene effettivamente cancellata
|
||||
// Tutti i parametri relativi al progress indicator
|
||||
// vengono settati da funzioni apposite (vedi oltre)
|
||||
// ****************************************************
|
||||
// Molte altre minchiatine (form feed automatici, header,
|
||||
// footer etc) sono spiegate nel seguito
|
||||
// ****************************************************
|
||||
|
||||
virtual void user_create() {}
|
||||
virtual void user_destroy() {}
|
||||
|
||||
// set print, bound to menu :Selezione:Stampa
|
||||
// chiamata automaticamente dopo user_create()
|
||||
virtual bool set_print(int i = 1) { return FALSE; }
|
||||
|
||||
// set_row functions MUST be called here in a switch
|
||||
// for each particular file being printed
|
||||
virtual void set_page(int file, int cnt) {}
|
||||
|
||||
// called before processing each page
|
||||
// used to set print strings from tables or files
|
||||
// not included in relation
|
||||
// returning FALSE cancels page printing
|
||||
// counter is the current print page number
|
||||
virtual bool preprocess_page(int file, int counter)
|
||||
{ return TRUE; }
|
||||
|
||||
// same before each print request
|
||||
// e.g. to initialize counters
|
||||
// returning FALSE cancels print request or subtree
|
||||
virtual bool preprocess_print(int file, int counter)
|
||||
{ return TRUE; }
|
||||
|
||||
// postprocessing; returning REPEAT_PAGE reprints the
|
||||
// whole page (after all sons are printed) or print
|
||||
// counter is the current page or print number
|
||||
virtual print_action postprocess_page(int file, int counter)
|
||||
{ return NEXT_PAGE; }
|
||||
virtual print_action postprocess_print(int file, int counter)
|
||||
{ return NEXT_PAGE; }
|
||||
// executed after all print job is completed
|
||||
virtual void postclose_print() {}
|
||||
|
||||
// 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;}
|
||||
|
||||
// bound to TApplication print menu
|
||||
// redefined ONLY for very special purposes
|
||||
virtual void print();
|
||||
|
||||
// bound to <select> menu and automatically called after
|
||||
// user_create()
|
||||
void do_print(int n);
|
||||
|
||||
public:
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// COME SETTARE LE RIGHE DI STAMPA
|
||||
// --------------------------------------------------------------
|
||||
// setrow() si usa come una printf per settare le righe di stampa
|
||||
// che vengono stampate da print()
|
||||
// I codici per gli argomenti variabili sono di 3 tipi:
|
||||
// @ si usa per stampare campi di database o informazioni di controllo
|
||||
// posizione carrello e font
|
||||
// ACHTUNG: i codici di formato sono diversi da quelli di printf e
|
||||
// sono elencati sotto. Per i campi di database occorre che il codice
|
||||
// sia accoppiato ad una delle funzioni FLD() passata come argomento;
|
||||
// questa provoca la stampa di campi della relazione corrente,
|
||||
// posizionata come e' stato deciso nell'inizializzazione
|
||||
// % 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
|
||||
// ignorato il carattere di riempimento eventualmente specificato
|
||||
// con set_fillchar. Cio' vale anche per i codici @ (vedi)
|
||||
// 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
|
||||
// viene interpretato con le stesse regole di %t in dsprintf per real
|
||||
// (come %d o %f) e di %s per TString. Il puntatore NON
|
||||
// viene memorizzato; per questo occorre il codice # (sotto).
|
||||
// # si usa come % (stessi codici di printf) ma memorizza gli argomenti
|
||||
// per riferimento: ovvero, ogni volta che la riga viene stampata
|
||||
// viene stampato il contenuto in quel momento (che si puo' cambiare
|
||||
// in una delle pre- o post- process). Cio' implica che:
|
||||
// 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
|
||||
// la fine della stampa
|
||||
// Quindi, attenzione a %s con TString ridimensionate; si possono
|
||||
// usare solo se predimensionate alla dimensione massima, ma e' meglio
|
||||
// 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.
|
||||
// Comunque, il modo corretto di adoperare il codice # e'
|
||||
// usarlo solo per stampare MEMBRI della classe derivata da TPrint_application
|
||||
// ----------------------------------------------
|
||||
// field codes (match one of FLD() functions)
|
||||
// @@ -> @
|
||||
// @[n[,{l|c|r}]s -> STRING: n = pad, lcr = alignment
|
||||
// @{[n[.d=0]]|[n[,{l|c|r}]]p}n
|
||||
// -> NUMBER: n = digits, d = decimals
|
||||
// p = picture string (first matching arg)
|
||||
// @[l]d -> DATE: l = full year
|
||||
// @f -> BOOL: prints si/no
|
||||
// @[n,{l|c|r}]t -> Translated field (must set translation)
|
||||
//
|
||||
// Tutti questi codici possono essere usati anche maiuscoli, il che inibisce
|
||||
// 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)
|
||||
// se non vengono date ulteriori specifiche di formato viene usata
|
||||
// una picture che e' "" per default, ma puo' essere modificata con
|
||||
// set_real_picture(). Anche questo e' assai carino.
|
||||
// Normalmente un real uguale a zero viene stampato come stringa vuota
|
||||
// a meno che non si specifichi set_print_zero([TRUE]).
|
||||
// ---------------------------------------------
|
||||
// codici posizionamento e movimento carrello
|
||||
// @<n>g vai a posizione n
|
||||
// @<n>j salta di n posizioni (in orizzontale)
|
||||
// codici stile
|
||||
// @b bold
|
||||
// @i italic
|
||||
// @u underlined
|
||||
// @r reset to normal
|
||||
// ---------------------------------------------------
|
||||
// CODICI COLORE PER VISUALIZZAZIONE E COLLEGAMENTO
|
||||
// ---------------------------------------------------
|
||||
// Se si vuole che in visualizzazione il testo sia colorato
|
||||
// si usa il codice $[]; tra le quadre si scrive il colore
|
||||
// di foreground, opzionalmente seguito da una virgola e dal
|
||||
// colore di background (bianco per default). I colori si
|
||||
// specificano con un singolo carattere come segue:
|
||||
// n nero
|
||||
// g verde
|
||||
// b blu
|
||||
// c cyan
|
||||
// y giallo
|
||||
// v magenta
|
||||
// m colore background maschere (azzurrotto)
|
||||
// d grigio scuro
|
||||
// l grigio chiaro
|
||||
// k grigio normale
|
||||
// ------------------------------------------------------
|
||||
// Se si fa enable_link(..) con un certo colore, tutto
|
||||
// cio; che e' scritto in quel colore diventa selezionabile
|
||||
// e alla sua selezione (premendo 'Collega') si puo' associare
|
||||
// un'azione in process_link. A quest'ultima viene passata
|
||||
// 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
|
||||
// rilettura di set_page() alla prossima volta
|
||||
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")
|
||||
// provoca la stampa automatica di stringhe al
|
||||
// posto di determinati valori dei campi se e' dato
|
||||
// il codice @t
|
||||
// Il posto giusto per chiamarla: user_create()
|
||||
// ---------------------------------------------
|
||||
void set_translation(int lognum, const char* field,
|
||||
const char* from, const char* to);
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// hypertext interface for viswin
|
||||
// --------------------------------------------------------
|
||||
// Quando si vogliono abilitare determinati colori come
|
||||
// indicatori di legame ipertestuale, si faccia enable_link
|
||||
// nella create. L' ID ritornato viene passato a process_link
|
||||
// assieme al testo selezionato
|
||||
int enable_link (const char* descr, char fg, char bg = 'w');
|
||||
void disable_link(char fg, char bg = 'w');
|
||||
void disable_links() { printer().links().destroy(); }
|
||||
// se si setta multiple a TRUE anziche' la descrizione del testo selezionato
|
||||
// viene passata a enable_link una tokenstring con tutte i 'bottoni' dello
|
||||
// stesso colore presenti sulla riga
|
||||
void set_multiple_link(bool on);
|
||||
|
||||
|
||||
// BACKGROUND PAINTING! Chefigata! poi vi spiego....
|
||||
void set_background(const char* bgdesc = NULL);
|
||||
|
||||
|
||||
// ---------------------------------------------
|
||||
// set/select cursor
|
||||
// ---------------------------------------------
|
||||
// selects i-th cursor
|
||||
// inutile se c'e' un cursore solo
|
||||
void select_cursor(int i);
|
||||
|
||||
// return i-th cursor without making it current
|
||||
TCursor* get_cursor(int i);
|
||||
// returns maximum row defined
|
||||
int get_maxrow() { return _maxrow; }
|
||||
|
||||
// adds cursor to class; return identifier
|
||||
// cursor* can be NULL: no file is used but
|
||||
// print_one is called and iterations are performed
|
||||
// by pre_ and post_ process
|
||||
int add_cursor(TCursor* c);
|
||||
|
||||
// retrieve current cursor
|
||||
TCursor* current_cursor() { return _cur; }
|
||||
|
||||
// ---------------------------------------------
|
||||
// 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)
|
||||
void set_auto_ff( bool b = TRUE)
|
||||
{ _auto_ff = b; }
|
||||
|
||||
// il carattere specificato con set_fillchar (default ' ') viene
|
||||
// usato per riempire davanti e dietro i campi in cui si e' specificata
|
||||
// una dimensione maggiore della lunghezza effettiva del contenuto,
|
||||
// (a meno che non si sia usato un codice di formato maiuscolo)
|
||||
void set_fillchar(char c)
|
||||
{ _fillchar = c; }
|
||||
|
||||
// riempie di righe vuote la pagina corrente fino alla dimensione
|
||||
// della pagina
|
||||
void fill_page(int from = -1);
|
||||
|
||||
// di solito basta e avanza quella di default
|
||||
virtual bool menu(MENU_TAG m);
|
||||
|
||||
virtual word class_id() const { return CLASS_PRINT_APPLICATION; }
|
||||
|
||||
// print menu is enabled when set_print returns TRUE
|
||||
void enable_print_menu();
|
||||
void disable_print_menu();
|
||||
void enable_setprint_menu();
|
||||
void disable_setprint_menu();
|
||||
|
||||
// header/footer (printf, not set_row analogues)
|
||||
// only understand @-codes for setting font attributes,
|
||||
// date and page number
|
||||
// plus every printf %-code
|
||||
|
||||
// con queste si possono ridefinire header e footer al
|
||||
// verificarsi di condizioni durante la stampa
|
||||
virtual void preprocess_header() {}
|
||||
virtual void preprocess_footer() {}
|
||||
|
||||
void set_header(int row, const char* fmt, ...);
|
||||
void set_footer(int row, const char* fmt, ...);
|
||||
void reset_header();
|
||||
void reset_footer();
|
||||
|
||||
// vedi sopra per capire
|
||||
void reset_files() { _reset_tree(_pr_tree); _pr_tree = NULL; }
|
||||
void add_file(int file, int from = 0);
|
||||
void add_file(const char* tab, int from = 0);
|
||||
|
||||
// set default picture for reals
|
||||
void set_real_picture(const char* p) { _picture = p; }
|
||||
void set_print_zero(bool b = TRUE) { _print_zero = b; }
|
||||
|
||||
// progress indicator control
|
||||
void set_wait_message(const char* m)
|
||||
{ _wmess = m; }
|
||||
void set_wait_bar(bool m)
|
||||
// default yes
|
||||
{ _wbar = m; }
|
||||
void set_wait_cancel(bool m)
|
||||
// default yes
|
||||
{ _wcancel = m; }
|
||||
void set_wait_threshold(int m)
|
||||
// minimum number of print items to show progress indicator;
|
||||
// default 2
|
||||
{ _wthr = m; }
|
||||
|
||||
// questa forza la progind anche se si stampa su video
|
||||
void force_progind(bool b = TRUE)
|
||||
{ _force_progind = b; }
|
||||
|
||||
// questa forza la rilettura delle setrow in set_page ad ogni
|
||||
// record stampato, in modo che i dati siano
|
||||
// sempre quelli del record corrente anche se si usano codici %
|
||||
// s'intende che rallenta un po' la stampa
|
||||
void force_setpage(bool b = TRUE)
|
||||
{ _force_setpage = b; }
|
||||
|
||||
void set_config_file(const char* s)
|
||||
{ _confpr = s; }
|
||||
word get_page_number()
|
||||
{ return printer().getcurrentpage(); }
|
||||
void set_page_number(word n)
|
||||
{ printer().setcurrentpage(n); }
|
||||
|
||||
|
||||
void repeat_print() { _repeat_print = TRUE; }
|
||||
|
||||
TPrint_application();
|
||||
virtual ~TPrint_application();
|
||||
};
|
||||
|
||||
// buon divertimento
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -642,7 +642,7 @@ bool set_windows_print_device (TMask_field & f, KEY key)
|
||||
|
||||
TPrinter::TPrinter()
|
||||
: _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;
|
||||
@ -662,6 +662,8 @@ TPrinter::TPrinter()
|
||||
_headersize = 0;
|
||||
_footersize = 0;
|
||||
_isopen = FALSE;
|
||||
_multiple_copies = MainApp()->class_id() == CLASS_PRINTER_APPLICATION;
|
||||
|
||||
// read configuration file
|
||||
read_configuration (_config);
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
@ -1148,7 +1150,8 @@ void TPrinter::set()
|
||||
((TList_field &) (mask.field (MSK_1_PRINTERS))).replace_items (pn1, pn2);
|
||||
mask.hide(MSK_1_SETUP);
|
||||
mask.hide(MSK_1_SIZE);
|
||||
mask.hide(MSK_1_LINES);
|
||||
mask.hide(MSK_1_LINES);
|
||||
if (!_multiple_copies) mask.hide(MSK_1_NPAGES);
|
||||
|
||||
pn1 = "";
|
||||
pn2 = "";
|
||||
@ -1171,11 +1174,7 @@ void TPrinter::set()
|
||||
mask.set (MSK_1_PRINTERS, format ("%d", _curprn));
|
||||
mask.set (MSK_1_CODES, format ("%d", _curcode));
|
||||
mask.set (MSK_1_FILENAME, _printerfile);
|
||||
|
||||
int nc = 1;
|
||||
if (MainApp()->class_id() == CLASS_PRINT_APPLICATION)
|
||||
nc = ((TPrint_application*)MainApp())->get_n_copies();
|
||||
mask.set(MSK_1_NPAGES, nc);
|
||||
mask.set(MSK_1_NPAGES, _ncopies);
|
||||
|
||||
mask.reset (MSK_1_SAVE);
|
||||
|
||||
@ -1195,9 +1194,7 @@ void TPrinter::set()
|
||||
// get user choices
|
||||
|
||||
_curprn = atoi(mask.get(MSK_1_PRINTERS));
|
||||
|
||||
if (MainApp()->class_id() == CLASS_PRINT_APPLICATION)
|
||||
((TPrint_application*)MainApp())->set_n_copies(atoi(mask.get(MSK_1_NPAGES)));
|
||||
_ncopies = atoi(mask.get(MSK_1_NPAGES));
|
||||
|
||||
PrinterDef& def = (PrinterDef &) get_description (_curprn);
|
||||
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);
|
||||
mask.set(MSK_1_PRINTERS, pn1.get(_curprn));
|
||||
|
||||
mask.hide(MSK_1_CODES);
|
||||
if (!_multiple_copies) mask.hide(MSK_1_NPAGES);
|
||||
|
||||
mask.set(MSK_1_ISGRAPHICS, _isgraphics ? "X" : "");
|
||||
mask.set(MSK_1_SIZE, _ch_size);
|
||||
mask.set(MSK_1_LINES, _lines_per_inch);
|
||||
|
||||
int nc = 1;
|
||||
if (MainApp()->class_id() == CLASS_PRINT_APPLICATION)
|
||||
nc = ((TPrint_application*)MainApp())->get_n_copies();
|
||||
mask.set(MSK_1_NPAGES, nc);
|
||||
mask.set(MSK_1_NPAGES, _ncopies);
|
||||
|
||||
if (_printertype == fileprinter)
|
||||
mask.set (MSK_1_TYPE, "1");
|
||||
@ -1312,8 +1309,7 @@ void TPrinter::set()
|
||||
mask.save ();
|
||||
}
|
||||
|
||||
if (MainApp()->class_id() == CLASS_PRINT_APPLICATION)
|
||||
((TPrint_application*)MainApp())->set_n_copies(atoi (mask.get (MSK_1_NPAGES)));
|
||||
_ncopies = atoi (mask.get (MSK_1_NPAGES));
|
||||
|
||||
switch (atoi (mask.get (MSK_1_TYPE)))
|
||||
{
|
||||
|
@ -1,357 +1,361 @@
|
||||
#ifndef __PRINTER_H
|
||||
#define __PRINTER_H
|
||||
|
||||
#ifndef __STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifndef __STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifndef __ARRAY_H
|
||||
#include <array.h>
|
||||
#endif
|
||||
|
||||
#ifndef __VISWIN_H
|
||||
#include <viswin.h>
|
||||
#endif
|
||||
|
||||
#ifndef __DATE_H
|
||||
#include <date.h>
|
||||
#endif
|
||||
|
||||
#ifndef __PRINTWIN_H
|
||||
#include <printwin.h>
|
||||
#endif
|
||||
|
||||
#ifndef __TEXT_H
|
||||
#include <text.h>
|
||||
#endif
|
||||
|
||||
// @DPUB
|
||||
enum TPrintstyle {
|
||||
normalstyle = 0,
|
||||
boldstyle = 1,
|
||||
underlinedstyle = 2,
|
||||
italicstyle = 3
|
||||
};
|
||||
|
||||
enum TPrtype {
|
||||
normprinter = 0,
|
||||
fileprinter = 1,
|
||||
spoolprinter = 2,
|
||||
localprinter = 3,
|
||||
screenvis = 4,
|
||||
winprinter = 5
|
||||
};
|
||||
|
||||
|
||||
// @END
|
||||
|
||||
// @C
|
||||
// class TPrintrow : public TObject
|
||||
// @END
|
||||
|
||||
class TPrintrow : public TObject
|
||||
{
|
||||
enum { MAXSTR = 256 };
|
||||
|
||||
// @DPROT
|
||||
TString256 _row; // the actual string to print
|
||||
char _attr[MAXSTR]; // contains char attributes of _row
|
||||
int _cols[MAXSTR]; // contains color attributes of _row
|
||||
TPrintstyle _currentstyle; // the current char attribute
|
||||
int _currentcolor; // the current color attribute
|
||||
int _lastpos; // last print position
|
||||
|
||||
public:
|
||||
// @FPUB
|
||||
TPrintrow();
|
||||
TPrintrow(const TPrintrow& pr);
|
||||
virtual ~TPrintrow() {}
|
||||
|
||||
// TPrintrow& center(const char* str, int position);
|
||||
virtual word class_id() const;
|
||||
virtual const char* class_name() const;
|
||||
virtual TObject* dup() const;
|
||||
|
||||
const char* row() const { return _row; }
|
||||
const char* row_codified();
|
||||
TPrintrow& reset();
|
||||
|
||||
TPrintstyle get_style(int position) const { return (TPrintstyle)_attr[position]; }
|
||||
TPrintstyle get_style() const { return _currentstyle; }
|
||||
int get_color(int position) const { return (TPrintstyle)_cols[position]; }
|
||||
int get_color() const { return _currentcolor; }
|
||||
TPrintrow& put(const char* str, int position = -1, int len=0);
|
||||
void set_style(TPrintstyle style) { _currentstyle=style; }
|
||||
int lastpos() const { return _lastpos; }
|
||||
};
|
||||
|
||||
class PrinterDef : public TObject
|
||||
{
|
||||
friend class TPrinter;
|
||||
TString _printername; // name of the printer file
|
||||
TString _printertype; // type of printer (0=diretta,1=locale,2=spool)
|
||||
TString _filtername; // filter for the pipe (UNIX only)
|
||||
TString _devicename; // name of print device
|
||||
char _atstr[4][10]; // attribute codes for the current printer
|
||||
TArray _codes; // print codes
|
||||
TArray _names; // name of print codes
|
||||
TString _ffcode; // formfeed code for the current printer
|
||||
TString _nlcode; // special newline code for the current printer
|
||||
|
||||
public:
|
||||
bool read(const char* name, FILE* fd); // read description from file;
|
||||
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_codes(word i) const { return i < (word) _codes.items() ? (const char*)(TString&)_codes[i] : NULL; }
|
||||
PrinterDef() : _printername(10), _filtername(10),
|
||||
_ffcode("\f"), _nlcode("\n")
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
class TPrinter;
|
||||
|
||||
typedef void (*PRINTSECTIONHANDLER)(TPrinter& printer);
|
||||
typedef void (*LINKHANDLER)(int, const char*);
|
||||
|
||||
|
||||
// @C
|
||||
// class TPrinter : public TObject
|
||||
// @END
|
||||
|
||||
class TPrinter : public TObject
|
||||
{
|
||||
// @DPROT
|
||||
|
||||
FILE* _cnfptr; // config file
|
||||
FILE* _fp; // pointer to the printer file
|
||||
TViswin* _vf; // pointer to file visualizer
|
||||
|
||||
TTextfile _txt;
|
||||
TFilename _config; // name of the configuration file
|
||||
int _headersize;
|
||||
int _footersize;
|
||||
TArray _header;
|
||||
TArray _footer;
|
||||
TArray _printers; // printers descriptions
|
||||
int _curprn; // current printer index
|
||||
int _curcode; // current printer index
|
||||
int _formlen; // length of the logic page
|
||||
int _currentrow; // next row to print
|
||||
int _ch_size;
|
||||
word _currentpage; // logic page containing _currentrow
|
||||
word _frompage; // first page to print (normally 0)
|
||||
word _topage; // last page to print (normally = USHRT_MAX)
|
||||
bool _hwformfeed; // if TRUE a ff will be printed after any footer
|
||||
TPrtype _printertype; // specifies the kind of output the user wants
|
||||
bool _isopen; // printer open
|
||||
TDate _date; // printing date
|
||||
TFilename _printerfile; // filename for printing on file
|
||||
TArray _linksdescr;
|
||||
bool _multiple_link; //
|
||||
TArray _background;
|
||||
const char* _bg_desc;
|
||||
TToken_string _printer_names;
|
||||
bool _isgraphics;
|
||||
bool _frozen;
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
PRINT_RCD* _print_rcd;
|
||||
int _print_rcd_size;
|
||||
#endif
|
||||
int _lines_per_inch;
|
||||
int _vert_offset;
|
||||
int _horz_offset;
|
||||
int _dots_per_line;
|
||||
|
||||
void _parse_background();
|
||||
void _get_windows_printer_names(TToken_string& t);
|
||||
|
||||
PRINTSECTIONHANDLER _headerhandler, _footerhandler;
|
||||
LINKHANDLER _linkhandler;
|
||||
|
||||
// @END
|
||||
|
||||
// @FPROT
|
||||
protected:
|
||||
virtual char newline() { return '\n'; }
|
||||
bool printrow (TPrintrow* rowtoprint=NULL); // base methods for printing
|
||||
bool printformfeed ();
|
||||
void read_configuration(const char* cfg);
|
||||
|
||||
bool printheader();
|
||||
bool printfooter();
|
||||
|
||||
public:
|
||||
|
||||
// @FPUB
|
||||
TPrinter ();
|
||||
virtual ~TPrinter();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
static BOOLEAN start_winprint(long);
|
||||
|
||||
#endif
|
||||
void set_config_file (const char * ffile) { _config = ffile ; }
|
||||
void set_from_page (word from) { _frompage = from; }
|
||||
void set_to_page (word to) { _topage = to; }
|
||||
void set_hwff (bool hwff) { _hwformfeed = hwff; }
|
||||
|
||||
int descriptions()
|
||||
{ return _printers.items(); }
|
||||
const PrinterDef& get_description(word i) const
|
||||
{ return (const PrinterDef&) _printers[i]; }
|
||||
virtual const char* class_name() const;
|
||||
virtual word class_id() const;
|
||||
|
||||
int formlen () const { return _formlen; }
|
||||
word frompage () const { return _frompage; }
|
||||
word topage () const { return _topage; }
|
||||
int headersize () const { return _headersize; }
|
||||
int footersize () const { return _footersize; }
|
||||
TPrintrow* getheaderline (int linetoget);
|
||||
TPrintrow* getfooterline (int linetoget);
|
||||
int formlen (int fl) { return (_formlen=fl); }
|
||||
int footerlen (int fl) { return (_footersize=fl); }
|
||||
int headerlen (int hl) { return (_headersize=hl); }
|
||||
word frompage (word fp) { return (_frompage=fp);}
|
||||
word topage (word tp) { return (_topage=tp); }
|
||||
void setheaderline (int linetoset, TPrintrow* line);
|
||||
void setheaderline (int linetoset, const TPrintrow& line);
|
||||
void setfooterline (int linetoset, TPrintrow* line);
|
||||
void setfooterline (int linetoset, const TPrintrow& line);
|
||||
void resetheader();
|
||||
void resetfooter();
|
||||
void setbackground(const char* bg);
|
||||
TArray* getbgdesc() { return &_background; }
|
||||
bool frozen() { return _frozen; }
|
||||
void freeze(bool b = TRUE) { _frozen = b; }
|
||||
|
||||
TToken_string& getprinternames();
|
||||
TTextfile& get_txt() { return _txt; }
|
||||
|
||||
void setheaderhandler(PRINTSECTIONHANDLER h) { _headerhandler = h; }
|
||||
void setfooterhandler(PRINTSECTIONHANDLER h) { _footerhandler = h; }
|
||||
|
||||
// used by viswin()
|
||||
// sono qui e non nella printapp per poter usare una viswin
|
||||
// completamente anche da un'altra application
|
||||
void setlinkhandler(LINKHANDLER h) { _linkhandler = h; }
|
||||
LINKHANDLER getlinkhandler() { return _linkhandler; }
|
||||
TArray& links() { return _linksdescr; }
|
||||
void setmultiplelink(bool on) { _multiple_link = on; }
|
||||
bool ismultiplelink() { return _multiple_link; }
|
||||
|
||||
bool skip (int linetoskip);
|
||||
bool jump (int linestojump);
|
||||
void reset ();
|
||||
virtual void set ();
|
||||
bool open ();
|
||||
void close ();
|
||||
bool formfeed ();
|
||||
bool print (TPrintrow& rowtoprint);
|
||||
bool isopen() { return _isopen; }
|
||||
void setdate(TDate& d) { _date = d; }
|
||||
TPrtype printtype() { return _printertype; }
|
||||
void set_printtype(TPrtype dest) { _printertype=dest; }
|
||||
void set_printerfile(const char * ffile) { _printerfile=ffile; }
|
||||
word getcurrentpage() { return _currentpage; }
|
||||
void setcurrentpage(word n) { _currentpage = n; }
|
||||
word rows() const { return _formlen-_headersize-_footersize; }
|
||||
word rows_left() const;
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
PRINT_RCD* get_printrcd() { return _print_rcd; }
|
||||
void set_printrcd(PRINT_RCD* p) { _print_rcd = p; }
|
||||
int& get_printrcdsize() { return _print_rcd_size; }
|
||||
void set_win_formlen();
|
||||
#endif
|
||||
void set_lines_per_inch(int n) { _lines_per_inch = n; }
|
||||
int get_lines_per_inch(int n) { return _lines_per_inch; }
|
||||
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
|
||||
int _num_rec_volume; // numero di record per disco
|
||||
int _num_rec_testa_coda; // numero di record per inizio e fine volume
|
||||
int _num_rec_inizio; // numero di record per inizio volume
|
||||
int _num_rec_fine; // numero di record per coda volume
|
||||
int _len_rec; // lunghezza record
|
||||
TArray _record; // array di tipi record
|
||||
bool _nome_file_fissato; // se il file sui dischetti deve avere un nome NON modificabile dall'utente
|
||||
bool _label_fissata; // se l'etichetta dei dischetti deve essere fissa
|
||||
bool _formatta;
|
||||
const char * _file; // file da generare sui dischetti
|
||||
const char * _label; // etichetta da scrivere sui dischetti
|
||||
TArray _tmp_files; // array dei file temporanei generati
|
||||
FILE * _fd;
|
||||
|
||||
// bool scrivi_volume();
|
||||
|
||||
public:
|
||||
|
||||
virtual char newline() { return '\0'; }
|
||||
void set_file_fissato (bool fissato) { _nome_file_fissato = fissato; }
|
||||
void set_label_fissata (bool fissata) { _label_fissata = fissata; }
|
||||
void set_len_rec (int len) { _len_rec = len; }
|
||||
|
||||
void set_file (const char * ffile) { _file = ffile; }
|
||||
void set_label (const char * label) { _label = label; }
|
||||
|
||||
void set_record (int record_to_set, TPrintrow* line)
|
||||
{_record.add(line, record_to_set); }
|
||||
|
||||
TPrintrow * get_record (int record_to_get)
|
||||
{return (TPrintrow *)&_record[record_to_get]; }
|
||||
|
||||
TPrintrow* get_record_inizio_volume() const { return (TPrintrow*)&_record[0];}
|
||||
TPrintrow* get_record_inizio_elenco() const {return (TPrintrow*)&_record[1];}
|
||||
TPrintrow* get_record_dettaglio() const { return (TPrintrow*)&_record[2]; }
|
||||
TPrintrow* get_record_fine_elenco() const {return (TPrintrow*)&_record[3]; }
|
||||
TPrintrow* get_record_fine_volume() const { return (TPrintrow*)&_record[4]; }
|
||||
TPrintrow* get_record_filler() const { return (TPrintrow*)&_record[5]; }
|
||||
|
||||
int num_rec_volume () { return _num_rec_volume; }
|
||||
int num_volumi () { return _volume; }
|
||||
void inc_volume () { _volume++; }
|
||||
|
||||
void add_file (TFilename nomef) { _tmp_files.add(nomef); }
|
||||
|
||||
void open();
|
||||
void close();
|
||||
|
||||
// void scrivi();
|
||||
bool genera_dischetti();
|
||||
|
||||
virtual void set ();
|
||||
|
||||
//
|
||||
// tipo_disco:
|
||||
// 0 per 360
|
||||
// 1 per 1.2
|
||||
// 2 per 720
|
||||
// 3 per 1,44
|
||||
// 4 per 2,88
|
||||
//
|
||||
TFile_printer (const char* file,
|
||||
const char* label,
|
||||
int len_rec,
|
||||
int num_rec_inizio = 1,
|
||||
int num_rec_fine = 1, int tipo_disco=0);
|
||||
|
||||
virtual ~TFile_printer();
|
||||
};
|
||||
|
||||
#endif // __PRINTER_H
|
||||
#ifndef __PRINTER_H
|
||||
#define __PRINTER_H
|
||||
|
||||
#ifndef __STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifndef __STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifndef __ARRAY_H
|
||||
#include <array.h>
|
||||
#endif
|
||||
|
||||
#ifndef __VISWIN_H
|
||||
#include <viswin.h>
|
||||
#endif
|
||||
|
||||
#ifndef __DATE_H
|
||||
#include <date.h>
|
||||
#endif
|
||||
|
||||
#ifndef __PRINTWIN_H
|
||||
#include <printwin.h>
|
||||
#endif
|
||||
|
||||
#ifndef __TEXT_H
|
||||
#include <text.h>
|
||||
#endif
|
||||
|
||||
// @DPUB
|
||||
enum TPrintstyle {
|
||||
normalstyle = 0,
|
||||
boldstyle = 1,
|
||||
underlinedstyle = 2,
|
||||
italicstyle = 3
|
||||
};
|
||||
|
||||
enum TPrtype {
|
||||
normprinter = 0,
|
||||
fileprinter = 1,
|
||||
spoolprinter = 2,
|
||||
localprinter = 3,
|
||||
screenvis = 4,
|
||||
winprinter = 5
|
||||
};
|
||||
|
||||
|
||||
// @END
|
||||
|
||||
// @C
|
||||
// class TPrintrow : public TObject
|
||||
// @END
|
||||
|
||||
class TPrintrow : public TObject
|
||||
{
|
||||
enum { MAXSTR = 256 };
|
||||
|
||||
// @DPROT
|
||||
TString256 _row; // the actual string to print
|
||||
char _attr[MAXSTR]; // contains char attributes of _row
|
||||
int _cols[MAXSTR]; // contains color attributes of _row
|
||||
TPrintstyle _currentstyle; // the current char attribute
|
||||
int _currentcolor; // the current color attribute
|
||||
int _lastpos; // last print position
|
||||
|
||||
public:
|
||||
// @FPUB
|
||||
TPrintrow();
|
||||
TPrintrow(const TPrintrow& pr);
|
||||
virtual ~TPrintrow() {}
|
||||
|
||||
// TPrintrow& center(const char* str, int position);
|
||||
virtual word class_id() const;
|
||||
virtual const char* class_name() const;
|
||||
virtual TObject* dup() const;
|
||||
|
||||
const char* row() const { return _row; }
|
||||
const char* row_codified();
|
||||
TPrintrow& reset();
|
||||
|
||||
TPrintstyle get_style(int position) const { return (TPrintstyle)_attr[position]; }
|
||||
TPrintstyle get_style() const { return _currentstyle; }
|
||||
int get_color(int position) const { return (TPrintstyle)_cols[position]; }
|
||||
int get_color() const { return _currentcolor; }
|
||||
TPrintrow& put(const char* str, int position = -1, int len=0);
|
||||
void set_style(TPrintstyle style) { _currentstyle=style; }
|
||||
int lastpos() const { return _lastpos; }
|
||||
};
|
||||
|
||||
class PrinterDef : public TObject
|
||||
{
|
||||
friend class TPrinter;
|
||||
TString _printername; // name of the printer file
|
||||
TString _printertype; // type of printer (0=diretta,1=locale,2=spool)
|
||||
TString _filtername; // filter for the pipe (UNIX only)
|
||||
TString _devicename; // name of print device
|
||||
char _atstr[4][10]; // attribute codes for the current printer
|
||||
TArray _codes; // print codes
|
||||
TArray _names; // name of print codes
|
||||
TString _ffcode; // formfeed code for the current printer
|
||||
TString _nlcode; // special newline code for the current printer
|
||||
|
||||
public:
|
||||
bool read(const char* name, FILE* fd); // read description from file;
|
||||
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_codes(word i) const { return i < (word) _codes.items() ? (const char*)(TString&)_codes[i] : NULL; }
|
||||
PrinterDef() : _printername(10), _filtername(10),
|
||||
_ffcode("\f"), _nlcode("\n")
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
class TPrinter;
|
||||
|
||||
typedef void (*PRINTSECTIONHANDLER)(TPrinter& printer);
|
||||
typedef void (*LINKHANDLER)(int, const char*);
|
||||
|
||||
|
||||
// @C
|
||||
// class TPrinter : public TObject
|
||||
// @END
|
||||
|
||||
class TPrinter : public TObject
|
||||
{
|
||||
// @DPROT
|
||||
|
||||
FILE* _cnfptr; // config file
|
||||
FILE* _fp; // pointer to the printer file
|
||||
TViswin* _vf; // pointer to file visualizer
|
||||
|
||||
TTextfile _txt;
|
||||
TFilename _config; // name of the configuration file
|
||||
int _headersize;
|
||||
int _footersize;
|
||||
TArray _header;
|
||||
TArray _footer;
|
||||
TArray _printers; // printers descriptions
|
||||
int _curprn; // current printer index
|
||||
int _curcode; // current printer index
|
||||
int _formlen; // length of the logic page
|
||||
int _currentrow; // next row to print
|
||||
int _ch_size;
|
||||
word _currentpage; // logic page containing _currentrow
|
||||
word _frompage; // first page to print (normally 0)
|
||||
word _topage; // last page to print (normally = USHRT_MAX)
|
||||
bool _hwformfeed; // if TRUE a ff will be printed after any footer
|
||||
TPrtype _printertype; // specifies the kind of output the user wants
|
||||
bool _isopen; // printer open
|
||||
TDate _date; // printing date
|
||||
TFilename _printerfile; // filename for printing on file
|
||||
TArray _linksdescr;
|
||||
bool _multiple_link; //
|
||||
TArray _background;
|
||||
const char* _bg_desc;
|
||||
TToken_string _printer_names;
|
||||
bool _isgraphics;
|
||||
bool _frozen;
|
||||
int _ncopies;
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
PRINT_RCD* _print_rcd;
|
||||
int _print_rcd_size;
|
||||
#endif
|
||||
int _lines_per_inch;
|
||||
int _vert_offset;
|
||||
int _horz_offset;
|
||||
int _dots_per_line;
|
||||
|
||||
void _parse_background();
|
||||
void _get_windows_printer_names(TToken_string& t);
|
||||
bool _multiple_copies;
|
||||
|
||||
PRINTSECTIONHANDLER _headerhandler, _footerhandler;
|
||||
LINKHANDLER _linkhandler;
|
||||
|
||||
// @END
|
||||
|
||||
// @FPROT
|
||||
protected:
|
||||
virtual char newline() { return '\n'; }
|
||||
bool printrow (TPrintrow* rowtoprint=NULL); // base methods for printing
|
||||
bool printformfeed ();
|
||||
void read_configuration(const char* cfg);
|
||||
|
||||
bool printheader();
|
||||
bool printfooter();
|
||||
|
||||
public:
|
||||
|
||||
// @FPUB
|
||||
TPrinter ();
|
||||
virtual ~TPrinter();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
static BOOLEAN start_winprint(long);
|
||||
|
||||
#endif
|
||||
void set_config_file (const char * ffile) { _config = ffile ; }
|
||||
void set_from_page (word from) { _frompage = from; }
|
||||
void set_to_page (word to) { _topage = to; }
|
||||
void set_hwff (bool hwff) { _hwformfeed = hwff; }
|
||||
|
||||
int descriptions()
|
||||
{ return _printers.items(); }
|
||||
const PrinterDef& get_description(word i) const
|
||||
{ return (const PrinterDef&) _printers[i]; }
|
||||
virtual const char* class_name() const;
|
||||
virtual word class_id() const;
|
||||
|
||||
int formlen () const { return _formlen; }
|
||||
word frompage () const { return _frompage; }
|
||||
word topage () const { return _topage; }
|
||||
int headersize () const { return _headersize; }
|
||||
int footersize () const { return _footersize; }
|
||||
TPrintrow* getheaderline (int linetoget);
|
||||
TPrintrow* getfooterline (int linetoget);
|
||||
int formlen (int fl) { return (_formlen=fl); }
|
||||
int footerlen (int fl) { return (_footersize=fl); }
|
||||
int headerlen (int hl) { return (_headersize=hl); }
|
||||
word frompage (word fp) { return (_frompage=fp);}
|
||||
word topage (word tp) { return (_topage=tp); }
|
||||
void setheaderline (int linetoset, TPrintrow* line);
|
||||
void setheaderline (int linetoset, const TPrintrow& line);
|
||||
void setfooterline (int linetoset, TPrintrow* line);
|
||||
void setfooterline (int linetoset, const TPrintrow& line);
|
||||
void resetheader();
|
||||
void resetfooter();
|
||||
void setbackground(const char* bg);
|
||||
TArray* getbgdesc() { return &_background; }
|
||||
bool frozen() { return _frozen; }
|
||||
void freeze(bool b = TRUE) { _frozen = b; }
|
||||
int n_copies() { return _ncopies; }
|
||||
void enable_multiple_copies(bool b = TRUE) { _multiple_copies = b; }
|
||||
|
||||
TToken_string& getprinternames();
|
||||
TTextfile& get_txt() { return _txt; }
|
||||
|
||||
void setheaderhandler(PRINTSECTIONHANDLER h) { _headerhandler = h; }
|
||||
void setfooterhandler(PRINTSECTIONHANDLER h) { _footerhandler = h; }
|
||||
|
||||
// used by viswin()
|
||||
// sono qui e non nella printapp per poter usare una viswin
|
||||
// completamente anche da un'altra application
|
||||
void setlinkhandler(LINKHANDLER h) { _linkhandler = h; }
|
||||
LINKHANDLER getlinkhandler() { return _linkhandler; }
|
||||
TArray& links() { return _linksdescr; }
|
||||
void setmultiplelink(bool on) { _multiple_link = on; }
|
||||
bool ismultiplelink() { return _multiple_link; }
|
||||
|
||||
bool skip (int linetoskip);
|
||||
bool jump (int linestojump);
|
||||
void reset ();
|
||||
virtual void set ();
|
||||
bool open ();
|
||||
void close ();
|
||||
bool formfeed ();
|
||||
bool print (TPrintrow& rowtoprint);
|
||||
bool isopen() { return _isopen; }
|
||||
void setdate(TDate& d) { _date = d; }
|
||||
TPrtype printtype() { return _printertype; }
|
||||
void set_printtype(TPrtype dest) { _printertype=dest; }
|
||||
void set_printerfile(const char * ffile) { _printerfile=ffile; }
|
||||
word getcurrentpage() { return _currentpage; }
|
||||
void setcurrentpage(word n) { _currentpage = n; }
|
||||
word rows() const { return _formlen-_headersize-_footersize; }
|
||||
word rows_left() const;
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
PRINT_RCD* get_printrcd() { return _print_rcd; }
|
||||
void set_printrcd(PRINT_RCD* p) { _print_rcd = p; }
|
||||
int& get_printrcdsize() { return _print_rcd_size; }
|
||||
void set_win_formlen();
|
||||
#endif
|
||||
void set_lines_per_inch(int n) { _lines_per_inch = n; }
|
||||
int get_lines_per_inch(int n) { return _lines_per_inch; }
|
||||
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
|
||||
int _num_rec_volume; // numero di record per disco
|
||||
int _num_rec_testa_coda; // numero di record per inizio e fine volume
|
||||
int _num_rec_inizio; // numero di record per inizio volume
|
||||
int _num_rec_fine; // numero di record per coda volume
|
||||
int _len_rec; // lunghezza record
|
||||
TArray _record; // array di tipi record
|
||||
bool _nome_file_fissato; // se il file sui dischetti deve avere un nome NON modificabile dall'utente
|
||||
bool _label_fissata; // se l'etichetta dei dischetti deve essere fissa
|
||||
bool _formatta;
|
||||
const char * _file; // file da generare sui dischetti
|
||||
const char * _label; // etichetta da scrivere sui dischetti
|
||||
TArray _tmp_files; // array dei file temporanei generati
|
||||
FILE * _fd;
|
||||
|
||||
// bool scrivi_volume();
|
||||
|
||||
public:
|
||||
|
||||
virtual char newline() { return '\0'; }
|
||||
void set_file_fissato (bool fissato) { _nome_file_fissato = fissato; }
|
||||
void set_label_fissata (bool fissata) { _label_fissata = fissata; }
|
||||
void set_len_rec (int len) { _len_rec = len; }
|
||||
|
||||
void set_file (const char * ffile) { _file = ffile; }
|
||||
void set_label (const char * label) { _label = label; }
|
||||
|
||||
void set_record (int record_to_set, TPrintrow* line)
|
||||
{_record.add(line, record_to_set); }
|
||||
|
||||
TPrintrow * get_record (int record_to_get)
|
||||
{return (TPrintrow *)&_record[record_to_get]; }
|
||||
|
||||
TPrintrow* get_record_inizio_volume() const { return (TPrintrow*)&_record[0];}
|
||||
TPrintrow* get_record_inizio_elenco() const {return (TPrintrow*)&_record[1];}
|
||||
TPrintrow* get_record_dettaglio() const { return (TPrintrow*)&_record[2]; }
|
||||
TPrintrow* get_record_fine_elenco() const {return (TPrintrow*)&_record[3]; }
|
||||
TPrintrow* get_record_fine_volume() const { return (TPrintrow*)&_record[4]; }
|
||||
TPrintrow* get_record_filler() const { return (TPrintrow*)&_record[5]; }
|
||||
|
||||
int num_rec_volume () { return _num_rec_volume; }
|
||||
int num_volumi () { return _volume; }
|
||||
void inc_volume () { _volume++; }
|
||||
|
||||
void add_file (TFilename nomef) { _tmp_files.add(nomef); }
|
||||
|
||||
void open();
|
||||
void close();
|
||||
|
||||
// void scrivi();
|
||||
bool genera_dischetti();
|
||||
|
||||
virtual void set ();
|
||||
|
||||
//
|
||||
// tipo_disco:
|
||||
// 0 per 360
|
||||
// 1 per 1.2
|
||||
// 2 per 720
|
||||
// 3 per 1,44
|
||||
// 4 per 2,88
|
||||
//
|
||||
TFile_printer (const char* file,
|
||||
const char* label,
|
||||
int len_rec,
|
||||
int num_rec_inizio = 1,
|
||||
int num_rec_fine = 1, int tipo_disco=0);
|
||||
|
||||
virtual ~TFile_printer();
|
||||
};
|
||||
|
||||
#endif // __PRINTER_H
|
||||
|
@ -1,36 +1,36 @@
|
||||
BUTTON DLG_SAVEREC 8 2
|
||||
BEGIN
|
||||
PROMPT -16 -1 "~Registra"
|
||||
MESSAGE EXIT,K_SAVE
|
||||
END
|
||||
|
||||
BUTTON DLG_NEWREC 8 2
|
||||
BEGIN
|
||||
PROMPT -26 -1 "~Nuovo"
|
||||
MESSAGE EXIT,K_INS
|
||||
END
|
||||
|
||||
BUTTON DLG_DELREC 8 2
|
||||
BEGIN
|
||||
PROMPT -36 -1 "~Elimina"
|
||||
MESSAGE EXIT,K_DEL
|
||||
END
|
||||
|
||||
BUTTON DLG_FINDREC 8 2
|
||||
BEGIN
|
||||
PROMPT -46 -1 "Ri~cerca"
|
||||
MESSAGE EXIT,K_F9
|
||||
END
|
||||
|
||||
BUTTON DLG_CANCEL 8 2
|
||||
BEGIN
|
||||
PROMPT -56 -1 ""
|
||||
MESSAGE EXIT,K_ESC
|
||||
END
|
||||
|
||||
BUTTON DLG_QUIT 8 2
|
||||
BEGIN
|
||||
PROMPT -66 -1 ""
|
||||
MESSAGE EXIT,K_QUIT
|
||||
END
|
||||
|
||||
BUTTON DLG_SAVEREC 8 2
|
||||
BEGIN
|
||||
PROMPT -16 -1 "~Registra"
|
||||
MESSAGE EXIT,K_SAVE
|
||||
END
|
||||
|
||||
BUTTON DLG_NEWREC 8 2
|
||||
BEGIN
|
||||
PROMPT -26 -1 "~Nuovo"
|
||||
MESSAGE EXIT,K_INS
|
||||
END
|
||||
|
||||
BUTTON DLG_DELREC 8 2
|
||||
BEGIN
|
||||
PROMPT -36 -1 "~Elimina"
|
||||
MESSAGE EXIT,K_DEL
|
||||
END
|
||||
|
||||
BUTTON DLG_FINDREC 8 2
|
||||
BEGIN
|
||||
PROMPT -46 -1 "Ri~cerca"
|
||||
MESSAGE EXIT,K_F9
|
||||
END
|
||||
|
||||
BUTTON DLG_CANCEL 8 2
|
||||
BEGIN
|
||||
PROMPT -56 -1 ""
|
||||
MESSAGE EXIT,K_ESC
|
||||
END
|
||||
|
||||
BUTTON DLG_QUIT 8 2
|
||||
BEGIN
|
||||
PROMPT -66 -1 ""
|
||||
MESSAGE EXIT,K_QUIT
|
||||
END
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user