Patch level : 10.0 508

Files correlati     : ba0 ve1 bagn001a.msk
Ricompilazione Demo : [ ]
Commento            :
Aggiunta possibilita' di forzare l'uso della stampante di default


git-svn-id: svn://10.65.10.50/trunk@19614 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2009-11-12 15:10:58 +00:00
parent 5e9a8a3cbe
commit 334fa27728
7 changed files with 100 additions and 51 deletions

@ -376,6 +376,9 @@ TInfo_mask::TInfo_mask() : TProperty_sheet(TR("Informazioni"))
add_prop(TR("Libreria GUI"), strwx);
add_prop(TR("Libreria PDF"), printer);
add_prop(TR("Libreria SQL"), strsql);
#ifdef WIN32
add_prop(TR("Libreria C++"), format("%d %d.%d", _MSC_VER/100, _MSC_VER%100/10, _MSC_VER%10));
#endif
set_read_only();
freeze(false);

@ -3,6 +3,7 @@
#define MSK_TYPE 101
#define MSK_FILENAME 102
#define MSK_PRINTERS 103
#define MSK_DEFAULT 104
#define MSK_ORIENTATION 333
#define MSK_ISGRAPHICS 334
#define MSK_SIZE 335

@ -1,80 +1,97 @@
#include <bagn001a.h>
PAGE "Impostazione Stampante" -1 -1 78 9
PAGE "Impostazione Stampante" -1 -1 78 11
RADIOBUTTON MSK_TYPE 1 76
BEGIN
PROMPT 1 0 "@bStampa su..."
ITEM "0|Stampante"
MESSAGE SHOW,MSK_PRINTERS|HIDE,MSK_FILENAME
MESSAGE SHOW,1@|HIDE,2@
ITEM "2|Visualizzazione"
MESSAGE SHOW,MSK_PRINTERS|HIDE,MSK_FILENAME
MESSAGE SHOW,1@|HIDE,2@
ITEM "1|File su disco"
MESSAGE HIDE,MSK_PRINTERS|SHOW,MSK_FILENAME
MESSAGE HIDE,1@|SHOW,2@
ITEM "4|Acrobat"
MESSAGE SHOW,MSK_PRINTERS|HIDE,MSK_FILENAME
MESSAGE SHOW,1@|HIDE,2@
FLAGS "Z"
END
BOOLEAN MSK_DEFAULT
BEGIN
PROMPT 1 3 "Utilizzare sempre la stampante predefinita di sistema"
MESSAGE FALSE ENABLE,MSK_PRINTERS
MESSAGE TRUE DISABLE,MSK_PRINTERS
GROUP 1
END
LIST MSK_PRINTERS 64
BEGIN
PROMPT 1 3 "Stampante "
PROMPT 1 4 "Stampante "
GROUP 1
END
STRING MSK_FILENAME 256 68
BEGIN
PROMPT 1 3 "File "
PROMPT 1 4 "File "
CHECKTYPE REQUIRED
VALIDATE FILENAME_FUNC
DSELECT
FLAGS "AM"
WARNING "E' necessario specificare un nome di file"
GROUP 2
END
GROUPBOX DLG_NULL 42 5
BEGIN
PROMPT 1 4 "@bCarattere standard"
PROMPT 1 5 "@bCarattere standard"
GROUP 1
END
LIST MSK_FONT 32
BEGIN
PROMPT 2 5 "Font "
PROMPT 2 6 "Font "
ITEM "Courier|Courier"
GROUP 1
END
LIST MSK_SIZE 3
BEGIN
PROMPT 2 6 "Dimensioni carattere "
PROMPT 2 7 "Dimensioni carattere "
ITEM "10|10"
GROUP 1
END
LIST MSK_LINES 3
BEGIN
PROMPT 2 7 "Linee per pollice "
PROMPT 2 8 "Linee per pollice "
ITEM "4|4"
ITEM "5|5"
ITEM "6|6"
ITEM "7|7"
ITEM "8|8"
ITEM "9|9"
ITEM "10|10"
ITEM "9|9"
ITEM "10|10"
GROUP 1
END
GROUPBOX DLG_NULL 33 5
BEGIN
PROMPT 44 4 "@bParametri di stampa"
PROMPT 44 5 "@bParametri di stampa"
GROUP 1
END
RADIOBUTTON MSK_ORIENTATION 1 30
BEGIN
PROMPT 45 4 ""
PROMPT 45 5 ""
ITEM "1|Foglio verticale"
ITEM "2|Foglio orizzontale"
GROUP 1
END
BOOLEAN MSK_ISGRAPHICS
BEGIN
PROMPT 46 7 "Elementi grafici"
PROMPT 46 8 "Elementi grafici"
GROUP 1
END
ENDPAGE

@ -5,13 +5,10 @@
#include <xvt.h>
#endif
#ifndef __OBJECT_H
#include <object.h>
#endif
#ifndef __STRINGS_H
#include <strings.h>
#endif
///////////////////////////////////////////////////////////
// TImage
///////////////////////////////////////////////////////////
@ -93,7 +90,7 @@ public:
void set_clut(byte n, COLOR c);
XVT_IMAGE xvt_image() const { return _image; }
operator XVT_IMAGE () const { return xvt_image(); }
operator XVT_IMAGE() const { return xvt_image(); }
static bool build_filename(TFilename & file);
// @cmember Costruttore. Viene passato il nome del file

@ -128,6 +128,16 @@ bool TPrinter_setup_mask::on_field_event(TOperable_field& o, TField_event e, lon
bool ok = true;
switch (o.dlg())
{
case MSK_DEFAULT:
if (fe_modify)
{
if (o.get().full())
{
set_print_rcd(NULL, 0);
set(MSK_PRINTERS, _pdev, 0x1);
}
}
break;
case MSK_PRINTERS:
if (fe_modify)
{
@ -205,7 +215,7 @@ bool TPrinter_setup_mask::on_field_event(TOperable_field& o, TField_event e, lon
}
TPrinter_setup_mask::TPrinter_setup_mask()
: TAutomask("bagn001a"), _pcd(NULL), _pcd_size(0), _pcd_owned(false)
: TAutomask("bagn001a"), _pcd(NULL), _pcd_size(0), _pcd_owned(false), _pdev(128)
{
TPrinter& pr = printer();
set(MSK_FILENAME, pr.get_printerfile());
@ -213,7 +223,10 @@ TPrinter_setup_mask::TPrinter_setup_mask()
const bool can_save = pr._config == "Printer";
enable(DLG_OK, can_save);
set_print_rcd(pr._print_rcd, pr._print_rcd_size);
if (pr.forced_default_printer())
set_print_rcd(NULL, 0);
else
set_print_rcd(pr._print_rcd, pr._print_rcd_size);
// Crea la lista delle stampanti
TToken_string pn2;
@ -225,7 +238,7 @@ TPrinter_setup_mask::TPrinter_setup_mask()
pn2.add(pname);
}
xvt_slist_destroy(plist);
_skip_events = true;
if (pr._printertype == fileprinter)
@ -239,7 +252,7 @@ TPrinter_setup_mask::TPrinter_setup_mask()
TList_field& plst = lfield (MSK_PRINTERS);
plst.replace_items(pn2, pn2); // Genera printer list
set(MSK_PRINTERS, pr._prname);
set(MSK_PRINTERS, _pdev);
_font = pr._fontname;
fill_font_list();
@ -250,6 +263,7 @@ TPrinter_setup_mask::TPrinter_setup_mask()
set(MSK_LINES, pr._lines_per_inch);
set(MSK_ISGRAPHICS, pr.isgraphics() ? "X" : "");
set(MSK_DEFAULT, pr.forced_default_printer() ? "X" : "");
TButton_tool& sp = (TButton_tool&)field(DLG_SETPRINT);
sp.set_exit_key(0); // Evita chiamate ricorsive all'impostazione stampante
@ -1188,7 +1202,7 @@ void TPrinter::set_printrcd()
}
bool ok = false;
if (_prname.not_empty())
if (_prname.full())
{
_print_rcd = xvt_print_create_by_name(&_print_rcd_size, _prname);
ok = xvt_print_is_valid(_print_rcd) != 0;
@ -1306,7 +1320,7 @@ void TPrinter::read_configuration(
TWait_cursor hourglass;
_config = parag; // Inizializza nome configurazione
if (_config.empty()) // Se non specificata ...
if (_config.blank()) // Se non specificata ...
_config = "Printer"; // ... usa configurazione standard
TConfig* iniptr = NULL;
@ -1325,31 +1339,35 @@ void TPrinter::read_configuration(
const int what = iniptr->get_int("Type", NULL, -1, 4); // Tipo stampante
_prname = iniptr->get("Name"); // Nome stampante corrente
_printerfile = iniptr->get("File", NULL, -1, ""); // File di stampa
set_fontname(iniptr->get("Font", NULL, -1, XVT_FFN_FIXED)); // Nome del font
set_fontname(iniptr->get("Font", NULL, -1, XVT_FFN_FIXED)); // Nome del font
_ch_size = iniptr->get_int("Size", NULL, -1, 10); // Dimensione del font
_lines_per_inch = iniptr->get_int("Lines", NULL, -1, 6); // Linee per pollice
set_graphics(iniptr->get_bool("Graphic", NULL, -1, true)); // Grafica attiva
_force_default = iniptr->get_bool("Default", NULL, -1, false); // Forza stampante di default
bool read_rcd = false;
const TString& host = iniptr->get("Host");
if (host.not_empty())
{
char hostname[256];
xvt_sys_get_host_name(hostname, sizeof(hostname));
read_rcd = (host == hostname); // Safe to read
if (!read_rcd)
{
read_rcd = yesno_box(FR("Attenzione: le impostazioni della stampante sono relative alla stazione di lavoro %s.\n"
"Si desidera utilizzarle ugualmente sulla stazione %s?"), (const char*)host, hostname);
if (!read_rcd)
if (_prname.full() && !forced_default_printer())
{
const TString& host = iniptr->get("Host");
if (host.full())
{
char hostname[256];
xvt_sys_get_host_name(hostname, sizeof(hostname));
read_rcd = (host == hostname); // Safe to read
if (!read_rcd)
{
// Forza la lettura parametri della stampante di default
_prname.cut(0);
set_printrcd();
read_rcd = yesno_box(FR("Attenzione: le impostazioni della stampante sono relative alla stazione di lavoro %s.\n"
"Si desidera utilizzarle ugualmente sulla stazione %s?"), (const char*)host, hostname);
if (!read_rcd)
{
// Forza la lettura parametri della stampante di default
_prname.cut(0);
set_printrcd();
}
}
}
}
}
}
if (read_rcd)
{
@ -1388,7 +1406,11 @@ void TPrinter::read_configuration(
"Si prega di selezionare e registrare una nuova stampante."));
set_printrcd();
}
}
}
else
{
set_printrcd();
}
delete iniptr; iniptr = NULL;
@ -1411,7 +1433,6 @@ void TPrinter::read_configuration(
}
}
void TPrinter::save_configuration(const char* para)
{
TWait_cursor hourglass;
@ -1428,6 +1449,7 @@ void TPrinter::save_configuration(const char* para)
prini.set("Size", _ch_size); // Dimensione del font
prini.set("Lines", _lines_per_inch); // Linee per pollice
prini.set("Graphic", _isgraphics ? "X" : ""); // Grafica attiva
prini.set("Default", _force_default ? "X" : ""); // Forza stampante default
char hostname[256];
xvt_sys_get_host_name(hostname, sizeof(hostname));
@ -1810,7 +1832,7 @@ bool TPrinter::set()
{
_manual_setup = true;
_print_rcd = mask.get_print_rcd(_print_rcd_size);
xvt_print_get_name(_print_rcd, _prname.get_buffer(80), 80);
xvt_print_get_name(_print_rcd, _prname.get_buffer(128), 128);
switch (mask.get_int(MSK_TYPE))
{
@ -1833,6 +1855,7 @@ bool TPrinter::set()
_lines_per_inch = mask.get_int (MSK_LINES);
_isgraphics = mask.get_bool (MSK_ISGRAPHICS);
_force_default = mask.get_bool(MSK_DEFAULT);
init_formlen ();
if (k == K_INS)

@ -271,10 +271,12 @@ class TPrinter : public TObject
// @cmember:(INTERNAL) Offset orizzontale in colonne (in caratteri)
int _c_offset;
// @cmember:(INTERNAL) Definizione dell stampa in punti per linea
int _dots_per_line;
int _dots_per_line;
// @cmember:(INTERNAL) Forza stampante di default
bool _force_default;
// @cmember:(INTERNAL) Setta <p t> con il profilo della stampante
void _get_windows_printer_names(TToken_string& t);
//void _get_windows_printer_names(TToken_string& t);
// @cmember:(INTERNAL) Indica se occorre esportare l'header di stampa
bool _export_header;
// @cmember:(INTERNAL) Lunghezza dell'header di stampa da esportare
@ -631,6 +633,9 @@ public:
bool is_portrait() const { return !is_landscape(); }
bool manual_setup() const { return _manual_setup; }
void force_default_printer(bool fdp) { _force_default = fdp; }
bool forced_default_printer() const { return _force_default; }
};
// @doc EXTERNAL

@ -177,7 +177,7 @@ RCT& xvtil_align_rect(const RCT& inner, const RCT& outer, char halign, char vali
const int oh = xvt_rect_get_height(&outer);
int iw = xvt_rect_get_width(&inner);
int ih = xvt_rect_get_height(&inner);
int ix = 0, iy = 0;
int ix = outer.left, iy = outer.top;
if (iw > ow || ih > oh)
{
if (grow == '-' || grow == '*')
@ -252,7 +252,10 @@ void TEvent_manager::push(WINDOW w, const EVENT& e)
_e[_end] = e;
const int next = (_end+1) % MAX;
if (next == _begin)
warning_box(FR("Hey %s, clicca piu' piano!"), (const char*)user());
{
TString msg; msg.format(FR("Hey %s, clicca piu' piano!"), (const char*)user());
xvt_dm_popup_message(msg);
}
else
_end = next;
}