Gestione dei font di stampa
git-svn-id: svn://10.65.10.50/trunk@1355 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
b9459a8656
commit
7abff04a85
@ -12,6 +12,7 @@ BEGIN
|
|||||||
MESSAGE ENABLE,MSK_1_CODES
|
MESSAGE ENABLE,MSK_1_CODES
|
||||||
MESSAGE ENABLE,MSK_1_SIZE
|
MESSAGE ENABLE,MSK_1_SIZE
|
||||||
MESSAGE ENABLE,MSK_1_LINES
|
MESSAGE ENABLE,MSK_1_LINES
|
||||||
|
MESSAGE ENABLE,MSK_1_FONT
|
||||||
MESSAGE ENABLE,DLG_SETPRINT
|
MESSAGE ENABLE,DLG_SETPRINT
|
||||||
ITEM "2|Visualizzazione"
|
ITEM "2|Visualizzazione"
|
||||||
MESSAGE HIDE,MSK_1_FILENAME
|
MESSAGE HIDE,MSK_1_FILENAME
|
||||||
@ -19,6 +20,7 @@ BEGIN
|
|||||||
MESSAGE DISABLE,MSK_1_CODES
|
MESSAGE DISABLE,MSK_1_CODES
|
||||||
MESSAGE DISABLE,MSK_1_SIZE
|
MESSAGE DISABLE,MSK_1_SIZE
|
||||||
MESSAGE DISABLE,MSK_1_LINES
|
MESSAGE DISABLE,MSK_1_LINES
|
||||||
|
MESSAGE DISABLE,MSK_1_FONT
|
||||||
MESSAGE DISABLE,DLG_SETPRINT
|
MESSAGE DISABLE,DLG_SETPRINT
|
||||||
ITEM "1|File su disco"
|
ITEM "1|File su disco"
|
||||||
MESSAGE SHOW,MSK_1_FILENAME
|
MESSAGE SHOW,MSK_1_FILENAME
|
||||||
@ -26,6 +28,7 @@ BEGIN
|
|||||||
MESSAGE ENABLE,MSK_1_CODES
|
MESSAGE ENABLE,MSK_1_CODES
|
||||||
MESSAGE DISABLE,MSK_1_SIZE
|
MESSAGE DISABLE,MSK_1_SIZE
|
||||||
MESSAGE DISABLE,MSK_1_LINES
|
MESSAGE DISABLE,MSK_1_LINES
|
||||||
|
MESSAGE DISABLE,MSK_1_FONT
|
||||||
MESSAGE DISABLE,DLG_SETPRINT
|
MESSAGE DISABLE,DLG_SETPRINT
|
||||||
FLAGS "Z"
|
FLAGS "Z"
|
||||||
END
|
END
|
||||||
@ -35,6 +38,7 @@ BEGIN
|
|||||||
/* viene riempito a run-time con nomi letti da config */
|
/* viene riempito a run-time con nomi letti da config */
|
||||||
PROMPT 4 5 "Stampante "
|
PROMPT 4 5 "Stampante "
|
||||||
HELP "Selezionare il tipo di stampante desiderata"
|
HELP "Selezionare il tipo di stampante desiderata"
|
||||||
|
FLAGS "G"
|
||||||
END
|
END
|
||||||
|
|
||||||
STRING MSK_1_FILENAME 52
|
STRING MSK_1_FILENAME 52
|
||||||
@ -51,17 +55,20 @@ LIST MSK_1_CODES 40
|
|||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 4 6 "Tipo stampa "
|
PROMPT 4 6 "Tipo stampa "
|
||||||
HELP "Modalita' nelle quale si desidera la stampa"
|
HELP "Modalita' nelle quale si desidera la stampa"
|
||||||
|
FLAGS "H"
|
||||||
|
END
|
||||||
|
|
||||||
|
LIST MSK_1_FONT 2 16
|
||||||
|
BEGIN
|
||||||
|
PROMPT 4 6 "Font "
|
||||||
|
HELP "Font di stampa su video o stampante"
|
||||||
|
ITEM "Courier|Courier"
|
||||||
END
|
END
|
||||||
|
|
||||||
LIST MSK_1_SIZE 3
|
LIST MSK_1_SIZE 3
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 31 6 "Carattere "
|
PROMPT 31 6 "Carattere "
|
||||||
// ITEM "7|7"
|
|
||||||
ITEM "8|8"
|
|
||||||
ITEM "10|10"
|
|
||||||
ITEM "12|12"
|
ITEM "12|12"
|
||||||
ITEM "15|15"
|
|
||||||
ITEM "17|17"
|
|
||||||
HELP "Dimensioni del carattere di stampa"
|
HELP "Dimensioni del carattere di stampa"
|
||||||
END
|
END
|
||||||
|
|
||||||
@ -78,15 +85,7 @@ BEGIN
|
|||||||
HELP "Numero di linee per pollice"
|
HELP "Numero di linee per pollice"
|
||||||
END
|
END
|
||||||
|
|
||||||
LIST MSK_1_FONT 10
|
NUMBER MSK_1_NPAGES 3
|
||||||
BEGIN
|
|
||||||
PROMPT 4 6 "Font "
|
|
||||||
HELP "Font di stampa su video o stampante"
|
|
||||||
ITEM "1|Courier"
|
|
||||||
FLAGS "D"
|
|
||||||
END
|
|
||||||
|
|
||||||
NUMBER MSK_1_NPAGES 3 0
|
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 54 8 "N.o copie "
|
PROMPT 54 8 "N.o copie "
|
||||||
HELP "Numero di copie da fare"
|
HELP "Numero di copie da fare"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: maskfld.h,v 1.27 1995-04-10 15:10:08 nik Exp $ */
|
/* $Id: maskfld.h,v 1.28 1995-05-10 15:39:56 guy Exp $ */
|
||||||
#ifndef __MASKFLD_H
|
#ifndef __MASKFLD_H
|
||||||
#define __MASKFLD_H
|
#define __MASKFLD_H
|
||||||
|
|
||||||
@ -466,7 +466,7 @@ protected:
|
|||||||
// @FPROT
|
// @FPROT
|
||||||
TToken_string _values;
|
TToken_string _values;
|
||||||
TToken_string _codes;
|
TToken_string _codes;
|
||||||
TString80 _str;
|
TString _str;
|
||||||
|
|
||||||
virtual word class_id() const;
|
virtual word class_id() const;
|
||||||
|
|
||||||
|
@ -382,8 +382,8 @@ bool PrinterDef::read (const char *name, FILE * fd)
|
|||||||
else if (l == "Code")
|
else if (l == "Code")
|
||||||
{
|
{
|
||||||
TToken_string code (r);
|
TToken_string code (r);
|
||||||
_names.add (TString (code.get ()));
|
_names.add ( code.get() );
|
||||||
_codes.add (TString (code.get ()));
|
_codes.add ( code.get() );
|
||||||
}
|
}
|
||||||
else if (l == "Form feed")
|
else if (l == "Form feed")
|
||||||
{
|
{
|
||||||
@ -510,8 +510,12 @@ TPrintrow & TPrintrow::put(const char *str, int position, int len)
|
|||||||
if (len < 1)
|
if (len < 1)
|
||||||
len = strlen (str);
|
len = strlen (str);
|
||||||
|
|
||||||
|
bool jumped = TRUE;
|
||||||
if (position < 0)
|
if (position < 0)
|
||||||
|
{
|
||||||
position = _lastpos;
|
position = _lastpos;
|
||||||
|
jumped = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
char bg = 'w', fg = 'n';
|
char bg = 'w', fg = 'n';
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
@ -556,13 +560,13 @@ TPrintrow & TPrintrow::put(const char *str, int position, int len)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
_currentstyle = boldstyle;
|
_currentstyle |= boldstyle;
|
||||||
break;
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
_currentstyle = italicstyle;
|
_currentstyle |= italicstyle;
|
||||||
break;
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
_currentstyle = underlinedstyle;
|
_currentstyle |= underlinedstyle;
|
||||||
break;
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
_currentstyle = normalstyle;
|
_currentstyle = normalstyle;
|
||||||
@ -626,11 +630,11 @@ TPrintrow & TPrintrow::put(const char *str, int position, int len)
|
|||||||
|
|
||||||
////////// TPRINTER //////////
|
////////// TPRINTER //////////
|
||||||
|
|
||||||
bool printers_on_key (TMask_field & f, KEY key)
|
HIDDEN bool printer_handler (TMask_field & f, KEY key)
|
||||||
{
|
{
|
||||||
if (key == K_SPACE)
|
if (key == K_SPACE)
|
||||||
{
|
{
|
||||||
TToken_string pn1 (10), pn2 (20);
|
TToken_string pn1(10), pn2(80);
|
||||||
|
|
||||||
const PrinterDef & def = printer().get_description(atoi(f.get ()));
|
const PrinterDef & def = printer().get_description(atoi(f.get ()));
|
||||||
const char *s;
|
const char *s;
|
||||||
@ -699,19 +703,71 @@ void TPrinter::set_win_formlen(WINDOW prwin)
|
|||||||
// Handler della maschera di setup
|
// Handler della maschera di setup
|
||||||
HIDDEN bool set_windows_print_device (TMask_field& f, KEY key)
|
HIDDEN bool set_windows_print_device (TMask_field& f, KEY key)
|
||||||
{
|
{
|
||||||
if (key == K_SPACE && f.mask().is_running())
|
if (key == K_SPACE)
|
||||||
{
|
{
|
||||||
TPrinter& pr = printer();
|
TPrinter& pr = printer();
|
||||||
|
|
||||||
|
TToken_string& pn = pr.getprinternames ();
|
||||||
|
TString80 pdev (pn.get(atoi (f.get()))); // Nome stampante corrente
|
||||||
|
|
||||||
char szDevice[80];
|
char szDevice[80];
|
||||||
TToken_string & pn = pr.getprinternames ();
|
|
||||||
TString pdev (pn.get (atoi (f.get())));
|
|
||||||
GetProfileString ("devices", pdev, "", szDevice, sizeof (szDevice));
|
GetProfileString ("devices", pdev, "", szDevice, sizeof (szDevice));
|
||||||
pdev << "," << szDevice;
|
pdev << "," << szDevice;
|
||||||
|
|
||||||
// scrivi (e semmai lo si risistema poi)
|
// scrivi (e semmai lo si risistema poi)
|
||||||
WriteProfileString("windows", "device", pdev);
|
WriteProfileString("windows", "device", pdev);
|
||||||
pr.set_printrcd();
|
pr.set_printrcd();
|
||||||
pr.set_win_formlen();
|
pr.set_win_formlen();
|
||||||
|
|
||||||
|
const int MAX_FAMILIES = 128;
|
||||||
|
char* family[MAX_FAMILIES];
|
||||||
|
const int num_families = (int)xvt_fmap_get_families(pr.get_printrcd(), family, MAX_FAMILIES);
|
||||||
|
TToken_string pn1(256), pn2(256);
|
||||||
|
for (int i = 0; i < num_families; i++)
|
||||||
|
{
|
||||||
|
pn1.add(family[i]);
|
||||||
|
pn2.add(family[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
TMask& m = f.mask();
|
||||||
|
TList_field& lst = (TList_field&)m.field(MSK_1_FONT);
|
||||||
|
|
||||||
|
lst.replace_items(pn1, pn2);
|
||||||
|
lst.set(printer().fontname());
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
HIDDEN bool font_handler(TMask_field& f, KEY key)
|
||||||
|
{
|
||||||
|
if (key == K_SPACE)
|
||||||
|
{
|
||||||
|
const char* family = f.get();
|
||||||
|
const int MAXSIZES = 32;
|
||||||
|
long sizes[MAXSIZES];
|
||||||
|
BOOLEAN scalable;
|
||||||
|
const int num_sizes = (int)xvt_fmap_get_family_sizes(printer().get_printrcd(),
|
||||||
|
(char*)family, sizes, &scalable, MAXSIZES);
|
||||||
|
|
||||||
|
TToken_string pn1(80), pn2(80);
|
||||||
|
|
||||||
|
if (scalable)
|
||||||
|
for (int i = 4; i <= 32; i++)
|
||||||
|
{
|
||||||
|
pn1.add(i);
|
||||||
|
pn2.add(i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
for (int i = 0; i < num_sizes; i++)
|
||||||
|
{
|
||||||
|
pn1.add(sizes[i]);
|
||||||
|
pn2.add(sizes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
TList_field& lst = (TList_field&)f.mask().field(MSK_1_SIZE);
|
||||||
|
const TString16 old(lst.get());
|
||||||
|
lst.replace_items(pn1, pn2);
|
||||||
|
lst.set(old);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -729,7 +785,6 @@ TPrinter::TPrinter()
|
|||||||
{
|
{
|
||||||
_footerhandler = _headerhandler = NULL;
|
_footerhandler = _headerhandler = NULL;
|
||||||
_linkhandler = NULL;
|
_linkhandler = NULL;
|
||||||
_config = "printer.ini";
|
|
||||||
_curprn = 0; // first in list if no default is specified
|
_curprn = 0; // first in list if no default is specified
|
||||||
|
|
||||||
_curcode = 0; // first in list if no default is specified
|
_curcode = 0; // first in list if no default is specified
|
||||||
@ -747,13 +802,9 @@ TPrinter::TPrinter()
|
|||||||
_multiple_copies = main_app().class_id() == CLASS_PRINT_APPLICATION;
|
_multiple_copies = main_app().class_id() == CLASS_PRINT_APPLICATION;
|
||||||
|
|
||||||
// read configuration file
|
// read configuration file
|
||||||
read_configuration (_config);
|
read_configuration ();
|
||||||
|
|
||||||
#if XVT_OS == XVT_OS_WIN
|
#if XVT_OS == XVT_OS_WIN
|
||||||
TConfig cnf (CONFIG_GENERAL, "Print");
|
|
||||||
_ch_size = cnf.get_int("Size", NULL, -1, 12);
|
|
||||||
_lines_per_inch = cnf.get_int("Lines", NULL, -1, 6);
|
|
||||||
|
|
||||||
// xvt_print_open ();
|
// xvt_print_open ();
|
||||||
set_win_formlen ();
|
set_win_formlen ();
|
||||||
|
|
||||||
@ -766,11 +817,8 @@ TPrinter::TPrinter()
|
|||||||
GetProfileString ("devices", pdev, "", szDevice, sizeof(szDevice));
|
GetProfileString ("devices", pdev, "", szDevice, sizeof(szDevice));
|
||||||
pdev.add(szDevice);
|
pdev.add(szDevice);
|
||||||
|
|
||||||
// get printer names
|
const TString80 p1(pdev.get(0)); // current printer
|
||||||
TToken_string pn2(1024);
|
TToken_string& pn2 = getprinternames(); // get printer names
|
||||||
_get_windows_printer_names(pn2);
|
|
||||||
|
|
||||||
const TString80 p1(pdev.get(0));
|
|
||||||
_curprn = pn2.get_pos(p1);
|
_curprn = pn2.get_pos(p1);
|
||||||
CHECKS(_curprn >= 0, "Can't find printer ", (const char*)p1);
|
CHECKS(_curprn >= 0, "Can't find printer ", (const char*)p1);
|
||||||
|
|
||||||
@ -783,17 +831,19 @@ TToken_string& TPrinter::getprinternames ()
|
|||||||
{
|
{
|
||||||
// per ora va solo in windows
|
// per ora va solo in windows
|
||||||
#if XVT_OS == XVT_OS_WIN
|
#if XVT_OS == XVT_OS_WIN
|
||||||
_get_windows_printer_names (_printer_names);
|
if (_printer_names.empty())
|
||||||
|
_get_windows_printer_names(_printer_names);
|
||||||
#endif
|
#endif
|
||||||
return _printer_names;
|
return _printer_names;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrinter::read_configuration(const char *conf)
|
void TPrinter::read_configuration()
|
||||||
{
|
{
|
||||||
|
#if XVT_OS == XVT_OS_SCOUNIX
|
||||||
FILE *cnfp = fopen (conf, "r");
|
const char* const config = "printer.ini";
|
||||||
|
FILE *cnfp = fopen (config, "r");
|
||||||
if (cnfp == NULL)
|
if (cnfp == NULL)
|
||||||
fatal_box ("Impossibile aprire il file %s", (const char *) _config);
|
fatal_box ("Impossibile aprire il file %s", config);
|
||||||
|
|
||||||
for (int i = 0; !feof (cnfp); i++)
|
for (int i = 0; !feof (cnfp); i++)
|
||||||
{
|
{
|
||||||
@ -822,41 +872,47 @@ void TPrinter::read_configuration(const char *conf)
|
|||||||
}
|
}
|
||||||
fclose (cnfp);
|
fclose (cnfp);
|
||||||
|
|
||||||
TFilename s ("printer.def");
|
#endif
|
||||||
|
|
||||||
|
TConfig prini(CONFIG_USER, "Printer");
|
||||||
|
|
||||||
|
const int what = prini.get_int("Type", NULL, -1, 0); // Tipo stampante
|
||||||
|
_curprn = prini.get_int("Number", NULL, -1, 0); // Numero stampante corrente
|
||||||
|
_printerfile = prini.get("File", NULL, -1, ""); // File di stampa
|
||||||
|
_curcode = prini.get_int("Codes", NULL, -1, 0); // Codici di stampa
|
||||||
|
_fontname = prini.get("Font", NULL, -1, XVT_FFN_FIXED); // Nome del font
|
||||||
|
_ch_size = prini.get_int("Size", NULL, -1, 12); // Dimensione del font
|
||||||
|
_lines_per_inch = prini.get_int("Lines", NULL, -1, 6); // Linee per pollice
|
||||||
|
_isgraphics = prini.get_bool("Graphic", NULL, -1, FALSE); // Grafica attiva
|
||||||
|
|
||||||
|
if (_printerfile.empty())
|
||||||
|
{
|
||||||
|
_printerfile.tempdir();
|
||||||
#if XVT_OS == XVT_OS_SCOUNIX
|
#if XVT_OS == XVT_OS_SCOUNIX
|
||||||
s << '.' << getuid ();
|
_printerfile << '/';
|
||||||
|
#else
|
||||||
|
_printerfile << '\\';
|
||||||
#endif
|
#endif
|
||||||
if (fexist (s))
|
}
|
||||||
|
|
||||||
|
switch (what)
|
||||||
{
|
{
|
||||||
TScanner sc (s);
|
case 0:
|
||||||
TToken_string t (sc.line ());
|
|
||||||
int where_print = t.get_int (1);
|
|
||||||
t = sc.line ();
|
|
||||||
_curprn = t.get_int(1);
|
|
||||||
t = sc.line ();
|
|
||||||
_printerfile = t.get (1);
|
|
||||||
t = sc.line ();
|
|
||||||
_curcode = t.get_int (1);
|
|
||||||
#if XVT_OS != XVT_OS_WIN
|
|
||||||
PrinterDef & def = (PrinterDef &) get_description (_curprn);
|
|
||||||
#endif
|
|
||||||
switch (where_print)
|
|
||||||
{
|
|
||||||
case 0: // stampante
|
|
||||||
#if XVT_OS == XVT_OS_WIN
|
#if XVT_OS == XVT_OS_WIN
|
||||||
_printertype = winprinter;
|
_printertype = winprinter;
|
||||||
#else
|
#else
|
||||||
|
PrinterDef & def = (PrinterDef &) get_description (_curprn);
|
||||||
switch (atoi (def._printertype))
|
switch (atoi (def._printertype))
|
||||||
{
|
{
|
||||||
case 0:
|
|
||||||
_printertype = normprinter;
|
|
||||||
break;
|
|
||||||
case 1:
|
case 1:
|
||||||
_printertype = localprinter;
|
_printertype = localprinter;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
_printertype = spoolprinter;
|
_printertype = spoolprinter;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
_printertype = normprinter;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
@ -867,7 +923,8 @@ void TPrinter::read_configuration(const char *conf)
|
|||||||
_printertype = screenvis;
|
_printertype = screenvis;
|
||||||
_curcode = 0;
|
_curcode = 0;
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1236,30 +1293,16 @@ _currentpage = 1;
|
|||||||
return _isopen = TRUE;
|
return _isopen = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TPrinter::set()
|
void TPrinter::set()
|
||||||
{
|
{
|
||||||
main_app().disable_menu_item (M_FILE_PG_SETUP);
|
main_app().disable_menu_item (M_FILE_PG_SETUP);
|
||||||
|
|
||||||
TMask mask ("bagn001a");
|
TMask mask("bagn001a");
|
||||||
TToken_string pn1 (50), pn2 (100);
|
|
||||||
|
TToken_string pn1(50), pn2(100);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (_printerfile.empty())
|
|
||||||
{
|
|
||||||
_printerfile.tempdir();
|
|
||||||
#if XVT_OS == XVT_OS_SCOUNIX
|
|
||||||
_printerfile << '/';
|
|
||||||
#else
|
|
||||||
_printerfile << '\\';
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
TFilename defile("printer.def");
|
|
||||||
#if XVT_OS == XVT_OS_SCOUNIX
|
|
||||||
defile << format (".%d", getuid ());
|
|
||||||
#endif
|
|
||||||
mask.set_workfile(defile);
|
|
||||||
|
|
||||||
mask.set(MSK_1_FILENAME, _printerfile);
|
mask.set(MSK_1_FILENAME, _printerfile);
|
||||||
mask.set(MSK_1_NPAGES, _ncopies);
|
mask.set(MSK_1_NPAGES, _ncopies);
|
||||||
|
|
||||||
@ -1278,9 +1321,7 @@ void TPrinter::set()
|
|||||||
if (!_multiple_copies)
|
if (!_multiple_copies)
|
||||||
mask.hide(MSK_1_NPAGES);
|
mask.hide(MSK_1_NPAGES);
|
||||||
|
|
||||||
pn1 = "";
|
pn1 = pn2 = "";
|
||||||
pn2 = "";
|
|
||||||
|
|
||||||
for (i = 0; i < ((PrinterDef &)_printers[_curprn])._names.items(); i++)
|
for (i = 0; i < ((PrinterDef &)_printers[_curprn])._names.items(); i++)
|
||||||
{
|
{
|
||||||
pn1.add(i);
|
pn1.add(i);
|
||||||
@ -1288,9 +1329,8 @@ void TPrinter::set()
|
|||||||
}
|
}
|
||||||
|
|
||||||
((TList_field &)(mask.field (MSK_1_CODES))).replace_items(pn1, pn2);
|
((TList_field &)(mask.field (MSK_1_CODES))).replace_items(pn1, pn2);
|
||||||
#if XVT_OS == XVT_OS_WIN
|
mask.xvt_win_set_handler (MSK_1_PRINTERS, printer_handler);
|
||||||
mask.xvt_win_set_handler (MSK_1_PRINTERS, printers_on_key);
|
|
||||||
#endif
|
|
||||||
if (_printertype == fileprinter)
|
if (_printertype == fileprinter)
|
||||||
mask.set (MSK_1_TYPE, "1");
|
mask.set (MSK_1_TYPE, "1");
|
||||||
else if (_printertype == screenvis)
|
else if (_printertype == screenvis)
|
||||||
@ -1299,7 +1339,10 @@ void TPrinter::set()
|
|||||||
mask.set (MSK_1_TYPE, "0");
|
mask.set (MSK_1_TYPE, "0");
|
||||||
|
|
||||||
mask.set(MSK_1_PRINTERS, _curprn);
|
mask.set(MSK_1_PRINTERS, _curprn);
|
||||||
|
|
||||||
|
mask.show(MSK_1_CODES);
|
||||||
mask.set(MSK_1_CODES, _curcode);
|
mask.set(MSK_1_CODES, _curcode);
|
||||||
|
|
||||||
KEY k;
|
KEY k;
|
||||||
|
|
||||||
if ((k = mask.run()) == K_ESC)
|
if ((k = mask.run()) == K_ESC)
|
||||||
@ -1346,23 +1389,27 @@ void TPrinter::set()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
mask.set_handler (MSK_1_PRINTERS, set_windows_print_device);
|
||||||
|
mask.set_handler (MSK_1_FONT, font_handler);
|
||||||
|
|
||||||
_get_windows_printer_names(pn2);
|
pn2 = getprinternames();
|
||||||
char old_default[80];
|
char old_default[80];
|
||||||
GetProfileString ("windows", "device", ",,,", old_default, sizeof(old_default));
|
GetProfileString ("windows", "device", ",,,", old_default, sizeof(old_default));
|
||||||
|
|
||||||
for (i = 0; i < pn2.items (); i++)
|
for (i = 0; i < pn2.items (); i++)
|
||||||
pn1.add(i);
|
pn1.add(i);
|
||||||
|
|
||||||
((TList_field &) (mask.field (MSK_1_PRINTERS))).replace_items(pn1, pn2);
|
TList_field& plst = (TList_field&)mask.field (MSK_1_PRINTERS);
|
||||||
mask.set(MSK_1_PRINTERS, pn1.get(_curprn));
|
plst.replace_items(pn1, pn2);
|
||||||
|
plst.set(pn1.get(_curprn));
|
||||||
|
|
||||||
mask.hide(MSK_1_CODES);
|
mask.set(MSK_1_FONT, _fontname);
|
||||||
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_SIZE, _ch_size);
|
||||||
mask.set(MSK_1_LINES, _lines_per_inch);
|
mask.set(MSK_1_LINES, _lines_per_inch);
|
||||||
|
mask.set(MSK_1_ISGRAPHICS, _isgraphics ? "X" : "");
|
||||||
|
|
||||||
|
if (!_multiple_copies)
|
||||||
|
mask.hide(MSK_1_NPAGES);
|
||||||
|
|
||||||
if (_printertype == fileprinter)
|
if (_printertype == fileprinter)
|
||||||
mask.set (MSK_1_TYPE, "1");
|
mask.set (MSK_1_TYPE, "1");
|
||||||
@ -1371,8 +1418,6 @@ void TPrinter::set()
|
|||||||
else
|
else
|
||||||
mask.set (MSK_1_TYPE, "0");
|
mask.set (MSK_1_TYPE, "0");
|
||||||
|
|
||||||
mask.set_handler (MSK_1_PRINTERS, set_windows_print_device);
|
|
||||||
|
|
||||||
KEY k;
|
KEY k;
|
||||||
int oldprn = _curprn;
|
int oldprn = _curprn;
|
||||||
|
|
||||||
@ -1399,22 +1444,12 @@ void TPrinter::set()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_curprn = atoi(mask.get(MSK_1_PRINTERS));
|
|
||||||
|
|
||||||
if (k == K_INS)
|
|
||||||
{
|
|
||||||
// tutto resta com'e'
|
|
||||||
mask.save ();
|
|
||||||
TConfig cnf (CONFIG_GENERAL, "Print");
|
|
||||||
cnf.set("Size", mask.get(MSK_1_SIZE), "12");
|
|
||||||
cnf.set("Lines", mask.get(MSK_1_LINES), "6");
|
|
||||||
}
|
|
||||||
if (k == K_ESC || k == K_ENTER)
|
if (k == K_ESC || k == K_ENTER)
|
||||||
{
|
{
|
||||||
// riaggiusta stampante default windows come prima
|
// riaggiusta stampante default windows come prima
|
||||||
// curprn e rcd sono quelle di prima
|
// curprn e rcd sono quelle di prima
|
||||||
main_app().enable_menu_item(M_FILE_PG_SETUP);
|
main_app().enable_menu_item(M_FILE_PG_SETUP);
|
||||||
WriteProfileString("windows","device", old_default);
|
WriteProfileString("windows", "device", old_default);
|
||||||
}
|
}
|
||||||
if (k == K_ESC)
|
if (k == K_ESC)
|
||||||
{
|
{
|
||||||
@ -1424,6 +1459,7 @@ void TPrinter::set()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_curprn = atoi(mask.get(MSK_1_PRINTERS));
|
||||||
_ncopies = atoi (mask.get (MSK_1_NPAGES));
|
_ncopies = atoi (mask.get (MSK_1_NPAGES));
|
||||||
|
|
||||||
switch (atoi (mask.get (MSK_1_TYPE)))
|
switch (atoi (mask.get (MSK_1_TYPE)))
|
||||||
@ -1442,11 +1478,28 @@ void TPrinter::set()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_isgraphics = mask.get_bool (MSK_1_ISGRAPHICS);
|
_fontname = mask.get(MSK_1_FONT);
|
||||||
_ch_size = mask.get_int (MSK_1_SIZE);
|
|
||||||
|
const int cs = mask.get_int(MSK_1_SIZE);
|
||||||
|
if (cs > 4) _ch_size = cs;
|
||||||
|
|
||||||
_lines_per_inch = mask.get_int (MSK_1_LINES);
|
_lines_per_inch = mask.get_int (MSK_1_LINES);
|
||||||
|
_isgraphics = mask.get_bool (MSK_1_ISGRAPHICS);
|
||||||
set_win_formlen ();
|
set_win_formlen ();
|
||||||
|
|
||||||
|
if (k == K_INS)
|
||||||
|
{
|
||||||
|
TConfig prini(CONFIG_USER, "Printer");
|
||||||
|
prini.set("Type", _printertype); // Tipo stampante
|
||||||
|
prini.set("Number", _curprn); // Numero stampante corrente
|
||||||
|
prini.set("File", _printerfile); // File di stampa
|
||||||
|
prini.set("Codes", _curcode); // Codici di stampa
|
||||||
|
prini.set("Font", _fontname); // Nome del font
|
||||||
|
prini.set("Size", _ch_size); // Dimensione del font
|
||||||
|
prini.set("Lines", _lines_per_inch); // Linee per pollice
|
||||||
|
prini.set("Graphic", _isgraphics ? "X" : ""); // Grafica attiva
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
main_app().enable_menu_item (M_FILE_PG_SETUP);
|
main_app().enable_menu_item (M_FILE_PG_SETUP);
|
||||||
|
@ -15,12 +15,14 @@
|
|||||||
|
|
||||||
|
|
||||||
// @DPUB
|
// @DPUB
|
||||||
enum TPrintstyle {
|
enum TPrintstyle
|
||||||
|
{
|
||||||
normalstyle = 0,
|
normalstyle = 0,
|
||||||
boldstyle = 1,
|
boldstyle = 1,
|
||||||
underlinedstyle = 2,
|
underlinedstyle = 2,
|
||||||
italicstyle = 3
|
italicstyle = 4,
|
||||||
};
|
jumpstyle = 64;
|
||||||
|
};
|
||||||
|
|
||||||
enum TPrtype {
|
enum TPrtype {
|
||||||
normprinter = 0,
|
normprinter = 0,
|
||||||
@ -83,19 +85,17 @@ class PrinterDef : public TObject
|
|||||||
TString _filtername; // filter for the pipe (UNIX only)
|
TString _filtername; // filter for the pipe (UNIX only)
|
||||||
TString _devicename; // name of print device
|
TString _devicename; // name of print device
|
||||||
char _atstr[4][10]; // attribute codes for the current printer
|
char _atstr[4][10]; // attribute codes for the current printer
|
||||||
TArray _codes; // print codes
|
TString_array _codes; // print codes
|
||||||
TArray _names; // name of print codes
|
TString_array _names; // name of print codes
|
||||||
TString _ffcode; // formfeed code for the current printer
|
TString _ffcode; // formfeed code for the current printer
|
||||||
TString _nlcode; // special newline code for the current printer
|
TString _nlcode; // special newline code for the current printer
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool read(const char* name, FILE* fd); // read description from file;
|
bool read(const char* name, FILE* fd); // read description from file;
|
||||||
bool isdefault(); // name matches "Default"
|
bool isdefault(); // name matches "Default"
|
||||||
const char* get_codenames(word i) const { return i < (word) _names.items() ? (const char*)(TString&)_names[i] : NULL; }
|
const char* get_codenames(word i) const { return i < (word)_names.items() ? (const char*)_names.row(i) : NULL; }
|
||||||
const char* get_codes(word i) const { return i < (word) _codes.items() ? (const char*)(TString&)_codes[i] : NULL; }
|
const char* get_codes(word i) const { return i < (word)_codes.items() ? (const char*)_codes.row(i) : NULL; }
|
||||||
PrinterDef() : _printername(10), _filtername(10),
|
PrinterDef() : _printername(10), _filtername(10), _ffcode("\f"), _nlcode("\n") {}
|
||||||
_ffcode("\f"), _nlcode("\n")
|
|
||||||
{}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -133,7 +133,6 @@ class TPrinter : public TObject
|
|||||||
TViswin* _vf; // pointer to file visualizer
|
TViswin* _vf; // pointer to file visualizer
|
||||||
|
|
||||||
TTextfile _txt;
|
TTextfile _txt;
|
||||||
TFilename _config; // name of the configuration file
|
|
||||||
TFilename _exportfile; // name of export file
|
TFilename _exportfile; // name of export file
|
||||||
int _headersize;
|
int _headersize;
|
||||||
int _footersize;
|
int _footersize;
|
||||||
@ -145,7 +144,10 @@ class TPrinter : public TObject
|
|||||||
int _formlen; // length of the logic page
|
int _formlen; // length of the logic page
|
||||||
int _formwidth; // size of the logic page
|
int _formwidth; // size of the logic page
|
||||||
int _currentrow; // next row to print
|
int _currentrow; // next row to print
|
||||||
|
|
||||||
|
TString80 _fontname; // Font name
|
||||||
int _ch_size; // Font height
|
int _ch_size; // Font height
|
||||||
|
|
||||||
word _currentpage; // logic page containing _currentrow
|
word _currentpage; // logic page containing _currentrow
|
||||||
word _frompage; // first page to print (normally 0)
|
word _frompage; // first page to print (normally 0)
|
||||||
word _topage; // last page to print (normally = USHRT_MAX)
|
word _topage; // last page to print (normally = USHRT_MAX)
|
||||||
@ -191,7 +193,7 @@ protected:
|
|||||||
virtual char newline() { return '\n'; }
|
virtual char newline() { return '\n'; }
|
||||||
bool printrow (TPrintrow* rowtoprint=NULL); // base methods for printing
|
bool printrow (TPrintrow* rowtoprint=NULL); // base methods for printing
|
||||||
bool printformfeed ();
|
bool printformfeed ();
|
||||||
void read_configuration(const char* cfg);
|
void read_configuration();
|
||||||
|
|
||||||
bool printheader();
|
bool printheader();
|
||||||
bool printfooter();
|
bool printfooter();
|
||||||
@ -206,7 +208,6 @@ public:
|
|||||||
static BOOLEAN XVT_CALLCONV1 start_winprint(long);
|
static BOOLEAN XVT_CALLCONV1 start_winprint(long);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void set_config_file (const char * ffile) { _config = ffile ; }
|
|
||||||
void set_from_page (word from) { _frompage = from; }
|
void set_from_page (word from) { _frompage = from; }
|
||||||
void set_to_page (word to) { _topage = to; }
|
void set_to_page (word to) { _topage = to; }
|
||||||
void set_hwff (bool hwff) { _hwformfeed = hwff; }
|
void set_hwff (bool hwff) { _hwformfeed = hwff; }
|
||||||
@ -304,7 +305,9 @@ public:
|
|||||||
int get_horz_offset() const { return _horz_offset; }
|
int get_horz_offset() const { return _horz_offset; }
|
||||||
int get_dots_per_line() const { return _dots_per_line; }
|
int get_dots_per_line() const { return _dots_per_line; }
|
||||||
bool isgraphics() const { return _isgraphics; }
|
bool isgraphics() const { return _isgraphics; }
|
||||||
|
|
||||||
int get_char_size() const { return _ch_size; }
|
int get_char_size() const { return _ch_size; }
|
||||||
|
char* fontname() const { return (char*)(const char*)_fontname; }
|
||||||
|
|
||||||
// bookmarks
|
// bookmarks
|
||||||
int set_bookmark(const char* txt, int father = -1);
|
int set_bookmark(const char* txt, int father = -1);
|
||||||
|
@ -6,17 +6,27 @@
|
|||||||
HIDDEN int LEN_SPACES(WINDOW win, int x)
|
HIDDEN int LEN_SPACES(WINDOW win, int x)
|
||||||
{
|
{
|
||||||
HIDDEN long w = 0L;
|
HIDDEN long w = 0L;
|
||||||
|
if (x < 0)
|
||||||
|
{
|
||||||
|
x = 80;
|
||||||
|
w = 0L;
|
||||||
|
}
|
||||||
if (w == 0L)
|
if (w == 0L)
|
||||||
{
|
{
|
||||||
TString256 spc; spc.spaces(256);
|
TString256 spc; spc.fill('M', 132);
|
||||||
w = xvt_dwin_get_text_width(win,(char*)(const char*)spc,256);
|
w = xvt_dwin_get_text_width(win,(char*)(const char*)spc, 132);
|
||||||
}
|
}
|
||||||
const int k = int((w*x) >> 8);
|
const int k = int((w*x) / 132);
|
||||||
|
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
TString256 spc; spc.spaces(x);
|
static bool error_on = TRUE;
|
||||||
|
if (error_on)
|
||||||
|
{
|
||||||
|
TString256 spc; spc.fill('M', x);
|
||||||
const int k1 = xvt_dwin_get_text_width(win,(char*)(const char*)spc,x);
|
const int k1 = xvt_dwin_get_text_width(win,(char*)(const char*)spc,x);
|
||||||
CHECK(k == k1, "Maguire disagrees");
|
if (k != k1)
|
||||||
|
error_on = error_box("Maguire disagrees: %d != %d", k, k1);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return k;
|
return k;
|
||||||
@ -148,34 +158,43 @@ void TPrintwin::paint_background(long j)
|
|||||||
|
|
||||||
void TPrintwin::paint_row(long j)
|
void TPrintwin::paint_row(long j)
|
||||||
{
|
{
|
||||||
char line[257];
|
const int row = (int)(j % _formlen);
|
||||||
|
const int y = row*_chary + _chary - _descent + _vofs;
|
||||||
const char* cp; int pos = 0;
|
|
||||||
int pixpos = 0;
|
|
||||||
int row = (int)(j % _formlen);
|
|
||||||
|
|
||||||
paint_background(j);
|
paint_background(j);
|
||||||
|
|
||||||
strcpy(line,_txt.line(j));
|
|
||||||
_txt.read_line(j);
|
_txt.read_line(j);
|
||||||
|
|
||||||
while(cp = _txt.piece())
|
int pos = 0;
|
||||||
|
|
||||||
|
const char* cp;
|
||||||
|
while((cp = _txt.piece()) != NULL)
|
||||||
{
|
{
|
||||||
pos += strlen(cp);
|
|
||||||
#if XVT_OS != XVT_OS_SCOUNIX
|
#if XVT_OS != XVT_OS_SCOUNIX
|
||||||
int st = _txt.get_style();
|
int st = _txt.get_style();
|
||||||
long bg = trans_color(_txt.get_background());
|
long bg = trans_color(_txt.get_background());
|
||||||
long fg = trans_color(_txt.get_foreground());
|
long fg = trans_color(_txt.get_foreground());
|
||||||
set_font(XVT_FFN_FIXED, st, _char_size);
|
set_font(printer().fontname(), st, _char_size);
|
||||||
set_color(fg,bg);
|
set_color(fg,bg);
|
||||||
#else
|
#else
|
||||||
set_color(COLOR_BLACK, COLOR_WHITE);
|
set_color(COLOR_BLACK, COLOR_WHITE);
|
||||||
#endif
|
#endif
|
||||||
xvt_dwin_draw_text(win(),
|
|
||||||
pixpos + _hofs,
|
const char* end = NULL;
|
||||||
row*_chary + _chary - _descent + _vofs,
|
for (const char* begin = cp; *begin; begin = end)
|
||||||
(char *)cp, -1);
|
{
|
||||||
pixpos = xvt_dwin_get_text_width(win(), line, pos);
|
for (; *begin == ' '; begin++)
|
||||||
|
pos++;
|
||||||
|
|
||||||
|
int len = 0;
|
||||||
|
for (end = begin; *end > ' ' || (*end && *(end+1) > ' '); end++)
|
||||||
|
len++;
|
||||||
|
|
||||||
|
if (*begin > ' ')
|
||||||
|
xvt_dwin_draw_text(win(), _hofs + LEN_SPACES(win(), pos), y, (char*)begin, len);
|
||||||
|
|
||||||
|
pos += len;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +231,7 @@ bool TPrintwin::do_print()
|
|||||||
&& (rct = xvt_print_get_next_band()) != NULL)
|
&& (rct = xvt_print_get_next_band()) != NULL)
|
||||||
{
|
{
|
||||||
set_font(XVT_FFN_SYSTEM, XVT_FS_NONE, _char_size);
|
set_font(XVT_FFN_SYSTEM, XVT_FS_NONE, _char_size);
|
||||||
set_font(XVT_FFN_FIXED, XVT_FS_NONE, _char_size);
|
set_font(printer().fontname(), XVT_FS_NONE, _char_size);
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
long size1 = xvt_dwin_get_font_size_mapped(win());
|
long size1 = xvt_dwin_get_font_size_mapped(win());
|
||||||
CHECK(size == size1, "Failed to set font. xvt bugs???");
|
CHECK(size == size1, "Failed to set font. xvt bugs???");
|
||||||
@ -235,33 +254,31 @@ TPrintwin::TPrintwin(TTextfile& txt)
|
|||||||
_printrcd = p.get_printrcd();
|
_printrcd = p.get_printrcd();
|
||||||
|
|
||||||
WINDOW prwin = xvt_print_create_win(_printrcd, (char*)(const char*)main_app().title());
|
WINDOW prwin = xvt_print_create_win(_printrcd, (char*)(const char*)main_app().title());
|
||||||
|
if (prwin == NULL_WIN)
|
||||||
|
{
|
||||||
|
_aborted = TRUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
set_win(prwin);
|
set_win(prwin);
|
||||||
#endif
|
#endif
|
||||||
_char_size = p.get_char_size();
|
|
||||||
|
|
||||||
set_font(XVT_FFN_FIXED, XVT_FS_NONE, _char_size);
|
_char_size = p.get_char_size();
|
||||||
|
set_font(p.fontname(), XVT_FS_NONE, _char_size);
|
||||||
|
LEN_SPACES(win(), -1); // force update
|
||||||
|
|
||||||
#if XVT_OS != XVT_OS_SCOUNIX
|
#if XVT_OS != XVT_OS_SCOUNIX
|
||||||
p.set_win_formlen(prwin); // Calcola offset e altre misure pagina
|
p.set_win_formlen(prwin); // Calcola offset e altre misure pagina
|
||||||
#endif
|
|
||||||
|
|
||||||
_inited = TRUE;
|
|
||||||
_formlen = p.formlen();
|
|
||||||
_formwidth = p.formwidth();
|
|
||||||
#if XVT_OS != XVT_OS_SCOUNIX
|
|
||||||
if (prwin != NULL_WIN)
|
|
||||||
{
|
|
||||||
xvt_dwin_get_font_metrics(prwin, &_lead, &_ascent, &_descent);
|
xvt_dwin_get_font_metrics(prwin, &_lead, &_ascent, &_descent);
|
||||||
|
|
||||||
_bg = &p.getbgdesc();
|
_bg = &p.getbgdesc();
|
||||||
|
|
||||||
_chary = p.get_dots_per_line();
|
_chary = p.get_dots_per_line();
|
||||||
_hofs = p.get_horz_offset();
|
_hofs = p.get_horz_offset();
|
||||||
_vofs = p.get_vert_offset();
|
_vofs = p.get_vert_offset();
|
||||||
}
|
|
||||||
else _aborted = TRUE;
|
|
||||||
#endif
|
#endif
|
||||||
LEN_SPACES(win(), 50); //debug
|
|
||||||
|
_formlen = p.formlen();
|
||||||
|
_formwidth = p.formwidth();
|
||||||
|
_inited = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user