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

stampa dopo un 'link' da viswin


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

View File

@ -1,20 +1,21 @@
// Header file for PRINT SETUP mask
#define MSK_1_TYPE 101
#define MSK_1_FILENAME 102
#define MSK_1_PRINTERS 103
#define MSK_1_CODES 111
// IMPORTANTE! lasciare il numero 111,
// in modo che la maschera sia compatibile
// con i metodi di ba2300, usati anche
// da printer
#define MSK_1_SAVE 112
#define MSK_1_SETUP 333
#define MSK_1_ISGRAPHICS 334
#define MSK_1_SIZE 335
#define MSK_1_LINES 336
#define MSK_1_PRINTERFILE prn.epf
#define MSK_1_NAMESFILE nms.epf
#define PRINTERSFILE "prn.epf"
#define NAMESFILE "nms.epf"
// Header file for PRINT SETUP mask
#define MSK_1_TYPE 101
#define MSK_1_FILENAME 102
#define MSK_1_PRINTERS 103
#define MSK_1_CODES 111
// IMPORTANTE! lasciare il numero 111,
// in modo che la maschera sia compatibile
// con i metodi di ba2300, usati anche
// da printer
#define MSK_1_SAVE 112
#define MSK_1_SETUP 333
#define MSK_1_ISGRAPHICS 334
#define MSK_1_SIZE 335
#define MSK_1_LINES 336
#define MSK_1_NPAGES 337
#define MSK_1_PRINTERFILE prn.epf
#define MSK_1_NAMESFILE nms.epf
#define PRINTERSFILE "prn.epf"
#define NAMESFILE "nms.epf"

View File

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

View File

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

View File

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

View File

@ -1,468 +1,473 @@
// 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
#ifndef __STRINGS_H
#include <strings.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;
// 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);
// 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); }
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
#ifndef __STRINGS_H
#include <strings.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);
// 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

View File

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

View File

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

View File

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