Patch level : 500
Files correlati : Ricompilazione Demo : [ ] Commento : AO20063 Su Win98 se scelgo una stampante Generica / solo testo come dimensione carattere mi riporta solo 0. git-svn-id: svn://10.65.10.50/trunk@11238 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
7a2dca9d28
commit
18ef8c0a4d
@ -7,35 +7,17 @@ BEGIN
|
|||||||
PROMPT 2 1 "Stampa su..."
|
PROMPT 2 1 "Stampa su..."
|
||||||
HELP "Selezionare il tipo dove direzionare la stampa"
|
HELP "Selezionare il tipo dove direzionare la stampa"
|
||||||
ITEM "0|Stampante"
|
ITEM "0|Stampante"
|
||||||
MESSAGE HIDE,MSK_FILENAME
|
MESSAGE SHOW,MSK_PRINTERS|HIDE,MSK_FILENAME
|
||||||
MESSAGE SHOW,MSK_PRINTERS|ENABLE,MSK_PRINTERS
|
|
||||||
MESSAGE ENABLE,MSK_SIZE
|
|
||||||
MESSAGE ENABLE,MSK_LINES
|
|
||||||
MESSAGE ENABLE,MSK_FONT
|
|
||||||
MESSAGE ENABLE,DLG_SETPRINT
|
|
||||||
ITEM "2|Visualizzazione"
|
ITEM "2|Visualizzazione"
|
||||||
MESSAGE HIDE,MSK_FILENAME
|
MESSAGE SHOW,MSK_PRINTERS|HIDE,MSK_FILENAME
|
||||||
MESSAGE SHOW,MSK_PRINTERS|DISABLE,MSK_PRINTERS
|
|
||||||
MESSAGE DISABLE,MSK_SIZE
|
|
||||||
MESSAGE DISABLE,MSK_LINES
|
|
||||||
MESSAGE DISABLE,MSK_FONT
|
|
||||||
MESSAGE DISABLE,DLG_SETPRINT
|
|
||||||
ITEM "1|File su disco"
|
ITEM "1|File su disco"
|
||||||
MESSAGE SHOW,MSK_FILENAME
|
MESSAGE HIDE,MSK_PRINTERS|SHOW,MSK_FILENAME
|
||||||
MESSAGE HIDE,MSK_PRINTERS
|
|
||||||
MESSAGE DISABLE,MSK_SIZE
|
|
||||||
MESSAGE DISABLE,MSK_LINES
|
|
||||||
MESSAGE DISABLE,MSK_FONT
|
|
||||||
MESSAGE DISABLE,DLG_SETPRINT
|
|
||||||
FLAGS "Z"
|
FLAGS "Z"
|
||||||
END
|
END
|
||||||
|
|
||||||
LIST MSK_PRINTERS 50
|
LIST MSK_PRINTERS 50
|
||||||
BEGIN
|
BEGIN
|
||||||
/* 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"
|
|
||||||
FLAGS "G"
|
|
||||||
END
|
END
|
||||||
|
|
||||||
STRING MSK_FILENAME 52
|
STRING MSK_FILENAME 52
|
||||||
@ -44,14 +26,12 @@ BEGIN
|
|||||||
CHECKTYPE REQUIRED
|
CHECKTYPE REQUIRED
|
||||||
VALIDATE FILENAME_FUNC
|
VALIDATE FILENAME_FUNC
|
||||||
FLAGS "A"
|
FLAGS "A"
|
||||||
HELP "Nome del file in cui memorizzare la stampa"
|
|
||||||
WARNING "E' necessario specificare un nome di file"
|
WARNING "E' necessario specificare un nome di file"
|
||||||
END
|
END
|
||||||
|
|
||||||
LIST MSK_FONT 32
|
LIST MSK_FONT 32
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 4 6 "Font "
|
PROMPT 4 6 "Font "
|
||||||
HELP "Font di stampa su video o stampante"
|
|
||||||
ITEM "Courier|Courier"
|
ITEM "Courier|Courier"
|
||||||
END
|
END
|
||||||
|
|
||||||
@ -59,7 +39,6 @@ LIST MSK_SIZE 3
|
|||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 53 6 "Carattere "
|
PROMPT 53 6 "Carattere "
|
||||||
ITEM "10|10"
|
ITEM "10|10"
|
||||||
HELP "Dimensioni del carattere di stampa"
|
|
||||||
END
|
END
|
||||||
|
|
||||||
LIST MSK_LINES 3
|
LIST MSK_LINES 3
|
||||||
@ -72,20 +51,16 @@ BEGIN
|
|||||||
ITEM "8|8"
|
ITEM "8|8"
|
||||||
ITEM "9|9"
|
ITEM "9|9"
|
||||||
ITEM "10|10"
|
ITEM "10|10"
|
||||||
HELP "Numero di linee per pollice"
|
|
||||||
END
|
END
|
||||||
|
|
||||||
BOOLEAN MSK_ISGRAPHICS
|
BOOLEAN MSK_ISGRAPHICS
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 4 8 "Stampa elementi grafici"
|
PROMPT 4 8 "Stampa elementi grafici"
|
||||||
HELP "Indicare se stampare elementi grafici (linee, box, logo) quando la stampante lo consente"
|
|
||||||
END
|
END
|
||||||
|
|
||||||
BUTTON DLG_SETPRINT 10 2
|
BUTTON DLG_SETPRINT 10 2
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT -14 -1 "~Imposta"
|
PROMPT -14 -1 "~Imposta"
|
||||||
HELP "Chiama l'Impostazione Stampante di Windows"
|
|
||||||
MESSAGE EXIT,DLG_SETPRINT
|
|
||||||
PICTURE 165
|
PICTURE 165
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -1979,18 +1979,19 @@ void TDropDownList::close()
|
|||||||
if (_open)
|
if (_open)
|
||||||
{
|
{
|
||||||
_open = FALSE;
|
_open = FALSE;
|
||||||
if (_xi_lst)
|
if (_xi_lst != NULL)
|
||||||
{
|
|
||||||
xvt_vobj_set_visible((WINDOW)xi_get_window(_xi_lst->itf), FALSE);
|
xvt_vobj_set_visible((WINDOW)xi_get_window(_xi_lst->itf), FALSE);
|
||||||
xvt_dwin_update((WINDOW)xi_get_window(_obj->itf));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDropDownList::destroy()
|
void TDropDownList::destroy()
|
||||||
{
|
{
|
||||||
_xi_lst = NULL;
|
close();
|
||||||
_open = FALSE;
|
if (_xi_lst != NULL)
|
||||||
|
{
|
||||||
|
xvt_vobj_destroy((WINDOW)xi_get_window(_xi_lst->itf));
|
||||||
|
_xi_lst = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TDropDownList::select(int i, bool force)
|
bool TDropDownList::select(int i, bool force)
|
||||||
@ -2071,8 +2072,14 @@ bool TDropDownList::select_by_ofs(int i)
|
|||||||
|
|
||||||
void TDropDownList::set_values(const char* c, const char* v)
|
void TDropDownList::set_values(const char* c, const char* v)
|
||||||
{
|
{
|
||||||
|
const int old_items = _codes.items();
|
||||||
|
|
||||||
_codes = c;
|
_codes = c;
|
||||||
_values = v;
|
_values = v;
|
||||||
|
|
||||||
|
const int new_items = _codes.items();
|
||||||
|
if (new_items != old_items && _xi_lst != NULL)
|
||||||
|
destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
int TDropDownList::calc_min_width()
|
int TDropDownList::calc_min_width()
|
||||||
@ -2089,7 +2096,8 @@ int TDropDownList::calc_min_width()
|
|||||||
|
|
||||||
void TDropDownList::create()
|
void TDropDownList::create()
|
||||||
{
|
{
|
||||||
if (_xi_lst) return;
|
if (_xi_lst != NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
XI_OBJ_DEF* itfdef = xi_create_itf_def(ITF_CID+1, (XI_EVENT_HANDLER)ddl_str_eh, NULL, "",
|
XI_OBJ_DEF* itfdef = xi_create_itf_def(ITF_CID+1, (XI_EVENT_HANDLER)ddl_str_eh, NULL, "",
|
||||||
(long)this);
|
(long)this);
|
||||||
@ -2183,14 +2191,14 @@ void TDropDownList::create()
|
|||||||
|
|
||||||
void TDropDownList::open()
|
void TDropDownList::open()
|
||||||
{
|
{
|
||||||
if (_xi_lst)
|
if (_open)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_xi_lst != NULL)
|
||||||
xvt_vobj_set_visible((WINDOW)xi_get_window(_xi_lst->itf), TRUE);
|
xvt_vobj_set_visible((WINDOW)xi_get_window(_xi_lst->itf), TRUE);
|
||||||
else
|
else
|
||||||
create();
|
create();
|
||||||
|
|
||||||
if (_open)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_open = TRUE;
|
_open = TRUE;
|
||||||
xi_cell_request(_xi_lst);
|
xi_cell_request(_xi_lst);
|
||||||
|
|
||||||
|
@ -323,7 +323,6 @@ public:
|
|||||||
virtual ~TDropDownList();
|
virtual ~TDropDownList();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TListbox_control : public TField_control
|
class TListbox_control : public TField_control
|
||||||
{
|
{
|
||||||
TDropDownList* _ddl;
|
TDropDownList* _ddl;
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#define XI_INTERNAL
|
#define XI_INTERNAL
|
||||||
#include <xinclude.h>
|
#include <xinclude.h>
|
||||||
|
|
||||||
@ -6,7 +8,6 @@ extern "C"
|
|||||||
#include <xiutils.h>
|
#include <xiutils.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
#include <colors.h>
|
#include <colors.h>
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <controls.h>
|
#include <controls.h>
|
||||||
@ -1068,7 +1069,7 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
|||||||
case CLASS_LIST_FIELD:
|
case CLASS_LIST_FIELD:
|
||||||
break; // Leave code as is
|
break; // Leave code as is
|
||||||
case CLASS_BOOLEAN_FIELD:
|
case CLASS_BOOLEAN_FIELD:
|
||||||
if (*src == ' ')
|
if (*src <= ' ')
|
||||||
xiev->v.cell_request.icon_rid = ICO_CHECK_OFF;
|
xiev->v.cell_request.icon_rid = ICO_CHECK_OFF;
|
||||||
else
|
else
|
||||||
xiev->v.cell_request.icon_rid = ICO_CHECK_ON;
|
xiev->v.cell_request.icon_rid = ICO_CHECK_ON;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <applicat.h>
|
#include <applicat.h>
|
||||||
|
#include <automask.h>
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <golem.h>
|
#include <golem.h>
|
||||||
#include <mask.h>
|
|
||||||
#include <printer.h>
|
#include <printer.h>
|
||||||
#include <printwin.h>
|
#include <printwin.h>
|
||||||
#include <urldefid.h>
|
#include <urldefid.h>
|
||||||
@ -15,6 +15,202 @@
|
|||||||
|
|
||||||
HIDDEN TPrinter* _printer = NULL;
|
HIDDEN TPrinter* _printer = NULL;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// Maschera impostazione stampante (fatta come si deve dopo 10 anni!)
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class TPrinter_setup_mask : public TAutomask
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
bool _skip_events;
|
||||||
|
|
||||||
|
TString _pdev, _font;
|
||||||
|
PRINT_RCD* _pcd;
|
||||||
|
int _pcd_size;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||||
|
|
||||||
|
void fill_font_list();
|
||||||
|
void fill_size_list();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void set_print_rcd(PRINT_RCD* pcd, int size);
|
||||||
|
PRINT_RCD* get_print_rcd(int& size) const;
|
||||||
|
|
||||||
|
TPrinter_setup_mask();
|
||||||
|
virtual ~TPrinter_setup_mask();
|
||||||
|
};
|
||||||
|
|
||||||
|
void TPrinter_setup_mask::set_print_rcd(PRINT_RCD* pcd, int size)
|
||||||
|
{
|
||||||
|
_pcd = pcd;
|
||||||
|
_pcd_size = size;
|
||||||
|
_pdev = ((const char*)pcd)+4;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRINT_RCD* TPrinter_setup_mask::get_print_rcd(int& size) const
|
||||||
|
{
|
||||||
|
size = _pcd_size;
|
||||||
|
return _pcd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TPrinter_setup_mask::fill_font_list()
|
||||||
|
{
|
||||||
|
const int MAX_FAMILIES = 128;
|
||||||
|
char* family[MAX_FAMILIES];
|
||||||
|
const int num_families = (int)xvt_fmap_get_families(_pcd, family, MAX_FAMILIES);
|
||||||
|
|
||||||
|
TToken_string fn(256);
|
||||||
|
for (int i = 0; i < num_families; i++)
|
||||||
|
{
|
||||||
|
fn.add(family[i]);
|
||||||
|
xvt_mem_free(family[i]);
|
||||||
|
}
|
||||||
|
TList_field& lst = (TList_field&)field(MSK_FONT);
|
||||||
|
lst.replace_items(fn, fn);
|
||||||
|
|
||||||
|
set(MSK_FONT, _font, 0x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TPrinter_setup_mask::fill_size_list()
|
||||||
|
{
|
||||||
|
const int MAXSIZES = 16;
|
||||||
|
long sizes[MAXSIZES];
|
||||||
|
BOOLEAN scalable;
|
||||||
|
|
||||||
|
const int num_sizes = (int)xvt_fmap_get_family_sizes(_pcd, _font.get_buffer(), sizes, &scalable, MAXSIZES);
|
||||||
|
|
||||||
|
TToken_string pn1;
|
||||||
|
if (scalable)
|
||||||
|
{
|
||||||
|
for (int i = 4; i <= 32; i++)
|
||||||
|
pn1.add(i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (num_sizes > 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < num_sizes; i++)
|
||||||
|
pn1.add(sizes[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pn1.add(printer().get_char_size()); // semper better than nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
TList_field& lst = (TList_field&)field(MSK_SIZE);
|
||||||
|
const TString8 old_size = lst.get();
|
||||||
|
lst.replace_items(pn1, pn1);
|
||||||
|
lst.set(old_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TPrinter_setup_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||||
|
{
|
||||||
|
if (_skip_events)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
switch (o.dlg())
|
||||||
|
{
|
||||||
|
case MSK_PRINTERS:
|
||||||
|
if (fe_modify)
|
||||||
|
{
|
||||||
|
const TString& pdev = o.get(); // Nome stampante corrente
|
||||||
|
if (pdev != _pdev)
|
||||||
|
{
|
||||||
|
TWait_cursor hourglass;
|
||||||
|
if (_pcd != NULL)
|
||||||
|
xvt_print_destroy(_pcd);
|
||||||
|
_pcd = xvt_print_create_by_name(&_pcd_size, pdev);
|
||||||
|
_pdev = pdev;
|
||||||
|
fill_font_list();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MSK_FONT:
|
||||||
|
if (e == fe_modify)
|
||||||
|
{
|
||||||
|
TWait_cursor hourglass;
|
||||||
|
const TString& family = o.get();
|
||||||
|
if (_font != family)
|
||||||
|
{
|
||||||
|
_font = family;
|
||||||
|
fill_size_list();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DLG_SETPRINT:
|
||||||
|
if (e == fe_button)
|
||||||
|
{
|
||||||
|
if (xvt_dm_post_page_setup(_pcd))
|
||||||
|
{
|
||||||
|
// see if user has changed printer
|
||||||
|
// determine index of currently selected printer
|
||||||
|
// ACTHUNG! Deep hacking of XVT internals! NON PORTABLE!
|
||||||
|
const char* name = (const char *)(_pcd) + 4;
|
||||||
|
set(MSK_PRINTERS, name, 0x1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TPrinter_setup_mask::TPrinter_setup_mask()
|
||||||
|
: TAutomask("bagn001a")
|
||||||
|
{
|
||||||
|
TPrinter& pr = printer();
|
||||||
|
set(MSK_FILENAME, pr.get_printerfile());
|
||||||
|
|
||||||
|
const bool can_save = pr._config == "Printer";
|
||||||
|
enable(DLG_OK, can_save);
|
||||||
|
|
||||||
|
set_print_rcd(pr._print_rcd, pr._print_rcd_size);
|
||||||
|
|
||||||
|
// Crea la lista delle stampanti
|
||||||
|
TToken_string pn2;
|
||||||
|
SLIST plist = xvt_print_list_devices();
|
||||||
|
for (SLIST_ELT pitem = xvt_slist_get_first(plist);
|
||||||
|
pitem != NULL; pitem = xvt_slist_get_next(plist, pitem))
|
||||||
|
{
|
||||||
|
const char* pname = xvt_slist_get(plist, pitem, NULL);
|
||||||
|
pn2.add(pname);
|
||||||
|
}
|
||||||
|
xvt_slist_destroy(plist);
|
||||||
|
|
||||||
|
_skip_events = TRUE;
|
||||||
|
|
||||||
|
TList_field& plst = (TList_field&)field (MSK_PRINTERS);
|
||||||
|
plst.replace_items(pn2, pn2); // Genera printer list
|
||||||
|
|
||||||
|
set(MSK_PRINTERS, pr._prname); // Genera font e size list
|
||||||
|
set(MSK_FONT, _font = pr._fontname);
|
||||||
|
set(MSK_SIZE, pr._ch_size);
|
||||||
|
set(MSK_LINES, pr._lines_per_inch);
|
||||||
|
set(MSK_ISGRAPHICS, pr._isgraphics ? "X" : "");
|
||||||
|
|
||||||
|
if (pr._printertype == fileprinter)
|
||||||
|
set (MSK_TYPE, "1");
|
||||||
|
else if (pr._printertype == screenvis)
|
||||||
|
set(MSK_TYPE, "2");
|
||||||
|
else
|
||||||
|
set(MSK_TYPE, "0");
|
||||||
|
|
||||||
|
fill_font_list();
|
||||||
|
fill_size_list();
|
||||||
|
|
||||||
|
_skip_events = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TPrinter_setup_mask::~TPrinter_setup_mask()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TPrinter
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TPrinter& printer()
|
TPrinter& printer()
|
||||||
{
|
{
|
||||||
if (_printer == NULL)
|
if (_printer == NULL)
|
||||||
@ -869,11 +1065,29 @@ TPrintrow& TPrintrow::put(const char *str, int position, int len)
|
|||||||
void TPrinter::set_printrcd()
|
void TPrinter::set_printrcd()
|
||||||
{
|
{
|
||||||
if (_print_rcd != NULL)
|
if (_print_rcd != NULL)
|
||||||
|
{
|
||||||
xvt_print_destroy(_print_rcd);
|
xvt_print_destroy(_print_rcd);
|
||||||
_print_rcd = xvt_print_create(&_print_rcd_size);
|
_print_rcd = NULL;
|
||||||
|
_print_rcd_size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!xvt_print_is_valid(_print_rcd))
|
bool ok = false;
|
||||||
error_box("Errore di inizializzazione della stampante");
|
if (_prname.not_empty())
|
||||||
|
{
|
||||||
|
_print_rcd = xvt_print_create_by_name(&_print_rcd_size, _prname);
|
||||||
|
ok = xvt_print_is_valid(_print_rcd) != 0;
|
||||||
|
if (!ok)
|
||||||
|
error_box(FR("Errore di inizializzazione della stampante %s"), (const char*)_prname);
|
||||||
|
}
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
_print_rcd = xvt_print_create(&_print_rcd_size);
|
||||||
|
ok = xvt_print_is_valid(_print_rcd) != 0;
|
||||||
|
if (ok)
|
||||||
|
_prname = ((const char*)_print_rcd)+4;
|
||||||
|
else
|
||||||
|
error_box(TR("Errore di inizializzazione della stampante corrente"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINT_RCD* TPrinter::get_printrcd(int *size)
|
PRINT_RCD* TPrinter::get_printrcd(int *size)
|
||||||
@ -933,82 +1147,6 @@ void TPrinter::init_formlen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handler della maschera di setup
|
|
||||||
HIDDEN bool set_windows_print_device (TMask_field& f, KEY key)
|
|
||||||
{
|
|
||||||
TMask& m = f.mask();
|
|
||||||
|
|
||||||
if (key == K_TAB && (f.focusdirty() || !m.is_running()))
|
|
||||||
{
|
|
||||||
TWait_cursor hourglass;
|
|
||||||
|
|
||||||
TPrinter& pr = printer();
|
|
||||||
const TString& pdev = f.get(); // Nome stampante corrente
|
|
||||||
xvt_print_set_default_device(pdev);
|
|
||||||
if (m.is_running())
|
|
||||||
{
|
|
||||||
pr.set_printrcd();
|
|
||||||
pr.init_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 fn(256);
|
|
||||||
|
|
||||||
for (int i = 0; i < num_families; i++)
|
|
||||||
{
|
|
||||||
fn.add(family[i]);
|
|
||||||
xvt_mem_free(family[i]);
|
|
||||||
}
|
|
||||||
TList_field& lst = (TList_field&)m.field(MSK_FONT);
|
|
||||||
|
|
||||||
lst.replace_items(fn, fn);
|
|
||||||
|
|
||||||
m.set(MSK_FONT, printer().fontname(), TRUE);
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
HIDDEN bool font_handler(TMask_field& f, KEY key)
|
|
||||||
{
|
|
||||||
TMask& m = f.mask();
|
|
||||||
|
|
||||||
if (key == K_TAB && (f.focusdirty() || !m.is_running()))
|
|
||||||
{
|
|
||||||
TWait_cursor hourglass;
|
|
||||||
|
|
||||||
const char* family = f.get();
|
|
||||||
const int MAXSIZES = 16;
|
|
||||||
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);
|
|
||||||
|
|
||||||
if (scalable)
|
|
||||||
{
|
|
||||||
for (int i = 4; i <= 32; i++)
|
|
||||||
pn1.add(i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (num_sizes > 0)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < num_sizes; i++)
|
|
||||||
pn1.add(sizes[i]);
|
|
||||||
}
|
|
||||||
else pn1.add(printer().get_char_size());
|
|
||||||
}
|
|
||||||
|
|
||||||
TList_field& lst = (TList_field&)f.mask().field(MSK_SIZE);
|
|
||||||
lst.replace_items(pn1, pn1);
|
|
||||||
lst.set(format("%d", printer().get_char_size()));
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
TPrinter::TPrinter()
|
TPrinter::TPrinter()
|
||||||
: _date (TODAY), _multiple_link (FALSE), _frozen (FALSE), _isgraphics (TRUE),
|
: _date (TODAY), _multiple_link (FALSE), _frozen (FALSE), _isgraphics (TRUE),
|
||||||
_lines_per_inch (6), _ch_size (12), _export_header(FALSE),
|
_lines_per_inch (6), _ch_size (12), _export_header(FALSE),
|
||||||
@ -1032,7 +1170,7 @@ TPrinter::TPrinter()
|
|||||||
_footersize = 0;
|
_footersize = 0;
|
||||||
_isopen = FALSE;
|
_isopen = FALSE;
|
||||||
|
|
||||||
xvt_print_get_default_device(_defPrinter.get_buffer(), _defPrinter.size());
|
// xvt_print_get_default_device(_defPrinter.get_buffer(), _defPrinter.size());
|
||||||
|
|
||||||
// read configuration file
|
// read configuration file
|
||||||
read_configuration ();
|
read_configuration ();
|
||||||
@ -1076,7 +1214,7 @@ void TPrinter::read_configuration(
|
|||||||
_prname = iniptr->get("Name", NULL, -1, _defPrinter); // Nome stampante corrente
|
_prname = iniptr->get("Name", NULL, -1, _defPrinter); // Nome stampante corrente
|
||||||
_printerfile = iniptr->get("File", NULL, -1, ""); // File di stampa
|
_printerfile = iniptr->get("File", NULL, -1, ""); // File di stampa
|
||||||
_fontname = iniptr->get("Font", NULL, -1, XVT_FFN_FIXED); // Nome del font
|
_fontname = iniptr->get("Font", NULL, -1, XVT_FFN_FIXED); // Nome del font
|
||||||
_ch_size = iniptr->get_int("Size", NULL, -1, 12); // Dimensione 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
|
_lines_per_inch = iniptr->get_int("Lines", NULL, -1, 6); // Linee per pollice
|
||||||
_isgraphics = iniptr->get_bool("Graphic", NULL, -1, TRUE); // Grafica attiva
|
_isgraphics = iniptr->get_bool("Graphic", NULL, -1, TRUE); // Grafica attiva
|
||||||
|
|
||||||
@ -1089,8 +1227,16 @@ void TPrinter::read_configuration(
|
|||||||
xvt_sys_get_host_name(hostname, sizeof(hostname));
|
xvt_sys_get_host_name(hostname, sizeof(hostname));
|
||||||
read_rcd = (host == hostname); // Safe to read
|
read_rcd = (host == hostname); // Safe to read
|
||||||
if (!read_rcd)
|
if (!read_rcd)
|
||||||
read_rcd = yesno_box("Le impostazioni della stampante sono relative alla stazione di lavoro %s:\n"
|
{
|
||||||
"si desidera applicarle ugualmente alla stazione %s?", (const char*)host, hostname);
|
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)
|
if (read_rcd)
|
||||||
@ -1099,7 +1245,7 @@ void TPrinter::read_configuration(
|
|||||||
xvt_print_destroy(_print_rcd);
|
xvt_print_destroy(_print_rcd);
|
||||||
_print_rcd = xvt_print_create_by_name(&_print_rcd_size, _prname);
|
_print_rcd = xvt_print_create_by_name(&_print_rcd_size, _prname);
|
||||||
|
|
||||||
if (_print_rcd != NULL && iniptr->exist("rcd", 0))
|
if (xvt_print_is_valid(_print_rcd) && iniptr->exist("rcd", 0))
|
||||||
{
|
{
|
||||||
TToken_string s(256);
|
TToken_string s(256);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -1139,24 +1285,15 @@ void TPrinter::read_configuration(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_config == "Printer" || _printertype == winprinter)
|
if (_config == "Printer" || _printertype == winprinter)
|
||||||
|
{
|
||||||
switch (what)
|
switch (what)
|
||||||
{
|
{
|
||||||
case 0:
|
case 1: _printertype = fileprinter; break;
|
||||||
case 5:
|
case 2: _printertype = screenvis; break;
|
||||||
_printertype = winprinter;
|
case 3: _printertype = export; break;
|
||||||
break;
|
default: _printertype = winprinter; break;
|
||||||
case 1: // file
|
|
||||||
_printertype = fileprinter;
|
|
||||||
break;
|
|
||||||
case 4: // video
|
|
||||||
_printertype = screenvis;
|
|
||||||
break;
|
|
||||||
case 6: // export
|
|
||||||
_printertype = export;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1175,12 +1312,10 @@ void TPrinter::save_configuration()
|
|||||||
prini.set("Lines", _lines_per_inch); // Linee per pollice
|
prini.set("Lines", _lines_per_inch); // Linee per pollice
|
||||||
prini.set("Graphic", _isgraphics ? "X" : ""); // Grafica attiva
|
prini.set("Graphic", _isgraphics ? "X" : ""); // Grafica attiva
|
||||||
|
|
||||||
#ifdef XVAGA
|
|
||||||
char hostname[80];
|
char hostname[80];
|
||||||
xvt_sys_get_host_name(hostname, sizeof(hostname));
|
xvt_sys_get_host_name(hostname, sizeof(hostname));
|
||||||
prini.set("Host", hostname);
|
prini.set("Host", hostname);
|
||||||
prini.set("User", user());
|
prini.set("User", user());
|
||||||
#endif
|
|
||||||
|
|
||||||
int n = 0, index = 0;
|
int n = 0, index = 0;
|
||||||
TToken_string val(256);
|
TToken_string val(256);
|
||||||
@ -1211,7 +1346,7 @@ TPrinter::~TPrinter ()
|
|||||||
xvt_print_destroy(_print_rcd);
|
xvt_print_destroy(_print_rcd);
|
||||||
_print_rcd = NULL;
|
_print_rcd = NULL;
|
||||||
}
|
}
|
||||||
xvt_print_set_default_device(_defPrinter);
|
// xvt_print_set_default_device(_defPrinter);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* TPrinter::class_name() const
|
const char* TPrinter::class_name() const
|
||||||
@ -1532,7 +1667,7 @@ void TPrinter::reset()
|
|||||||
|
|
||||||
bool TPrinter::open()
|
bool TPrinter::open()
|
||||||
{
|
{
|
||||||
xvt_print_set_default_device(_prname);
|
// xvt_print_set_default_device(_prname);
|
||||||
|
|
||||||
if (_printertype == screenvis)
|
if (_printertype == screenvis)
|
||||||
{
|
{
|
||||||
@ -1557,122 +1692,56 @@ bool TPrinter::open()
|
|||||||
return _isopen = TRUE;
|
return _isopen = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TPrinter::set()
|
bool TPrinter::set()
|
||||||
{
|
{
|
||||||
main_app().disable_menu_item (M_FILE_PG_SETUP);
|
main_app().disable_menu_item(M_FILE_PG_SETUP);
|
||||||
|
|
||||||
TMask mask("bagn001a");
|
|
||||||
|
|
||||||
mask.set(MSK_FILENAME, _printerfile);
|
|
||||||
|
|
||||||
const bool can_save = _config == "Printer";
|
|
||||||
mask.enable(DLG_OK, can_save);
|
|
||||||
|
|
||||||
// Crea la lista delle stampanti
|
|
||||||
TToken_string pn2;
|
|
||||||
SLIST plist = xvt_print_list_devices();
|
|
||||||
for (SLIST_ELT pitem = xvt_slist_get_first(plist);
|
|
||||||
pitem != NULL; pitem = xvt_slist_get_next(plist, pitem))
|
|
||||||
{
|
|
||||||
const char* pname = xvt_slist_get(plist, pitem, NULL);
|
|
||||||
pn2.add(pname);
|
|
||||||
}
|
|
||||||
xvt_slist_destroy(plist);
|
|
||||||
|
|
||||||
TList_field& plst = (TList_field&)mask.field (MSK_PRINTERS);
|
|
||||||
plst.replace_items(pn2, pn2); // Genera printer list
|
|
||||||
|
|
||||||
mask.set(MSK_PRINTERS, _prname); // Genera font list
|
|
||||||
set_windows_print_device(mask.field(MSK_PRINTERS), K_TAB);
|
|
||||||
|
|
||||||
mask.set(MSK_FONT, _fontname); // Genera size list
|
|
||||||
font_handler(mask.field(MSK_FONT),K_TAB);
|
|
||||||
|
|
||||||
mask.set(MSK_SIZE, _ch_size);
|
|
||||||
mask.set(MSK_LINES, _lines_per_inch);
|
|
||||||
mask.set(MSK_ISGRAPHICS, _isgraphics ? "X" : "");
|
|
||||||
|
|
||||||
mask.set_handler(MSK_PRINTERS, set_windows_print_device);
|
|
||||||
mask.set_handler(MSK_FONT, font_handler);
|
|
||||||
|
|
||||||
if (_printertype == fileprinter)
|
|
||||||
mask.set (MSK_TYPE, "1");
|
|
||||||
else if (_printertype == screenvis)
|
|
||||||
mask.set (MSK_TYPE, "2");
|
|
||||||
else
|
|
||||||
mask.set (MSK_TYPE, "0");
|
|
||||||
|
|
||||||
const TString oldprn = _prname;
|
const TString oldprn = _prname;
|
||||||
PRINT_RCD* rcd = get_printrcd();
|
int old_rcd_size;
|
||||||
|
PRINT_RCD* rcd = get_printrcd(&old_rcd_size);
|
||||||
const int old_rcd_size = _print_rcd_size;
|
|
||||||
TString oldrcd(old_rcd_size);
|
TString oldrcd(old_rcd_size);
|
||||||
memcpy(oldrcd.get_buffer(), rcd, old_rcd_size);
|
memcpy(oldrcd.get_buffer(), rcd, old_rcd_size);
|
||||||
|
|
||||||
KEY k;
|
TPrinter_setup_mask mask;
|
||||||
while ((k = mask.run()) != K_ESC && k != K_ENTER && k != K_INS)
|
const KEY k = mask.run();
|
||||||
{
|
_print_rcd = mask.get_print_rcd(_print_rcd_size);
|
||||||
if (k == DLG_SETPRINT)
|
|
||||||
{
|
|
||||||
// l'handler setta default di windows a quella nel listbox e ribecca l'rcd
|
|
||||||
if (xvt_dm_post_page_setup(get_printrcd()))
|
|
||||||
{
|
|
||||||
// see if user has changed printer
|
|
||||||
// determine index of currently selected printer
|
|
||||||
// ACTHUNG! Deep hacking of XVT internals! NON PORTABLE!
|
|
||||||
_prname = (const char *)(get_printrcd()) + 4;
|
|
||||||
if (_prname.blank())
|
|
||||||
_prname = oldprn;
|
|
||||||
|
|
||||||
mask.set(MSK_PRINTERS, _prname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (k == K_ESC)
|
if (k == K_ESC)
|
||||||
{
|
{
|
||||||
// riaggiusta stampante default windows come prima
|
xvt_print_destroy(_print_rcd);
|
||||||
// curprn e rcd sono quelle di prima
|
_print_rcd = xvt_print_create_by_name(&_print_rcd_size, oldprn);
|
||||||
main_app().enable_menu_item(M_FILE_PG_SETUP);
|
memcpy(_print_rcd, oldrcd, _print_rcd_size);
|
||||||
xvt_print_set_default_device(oldprn);
|
|
||||||
_prname = oldprn;
|
|
||||||
PRINT_RCD* rcd = get_printrcd();
|
|
||||||
memcpy(rcd, (const char *)oldrcd, old_rcd_size);
|
|
||||||
init_formlen();
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
_prname = mask.get(MSK_PRINTERS);
|
|
||||||
|
|
||||||
switch (atoi (mask.get (MSK_TYPE)))
|
|
||||||
{
|
{
|
||||||
case 0: // stampante
|
_prname = mask.get(MSK_PRINTERS);
|
||||||
_printertype = winprinter;
|
|
||||||
break;
|
switch (atoi (mask.get (MSK_TYPE)))
|
||||||
case 1: // file
|
{
|
||||||
_printertype = fileprinter;
|
case 1: // file
|
||||||
_printerfile = mask.get (MSK_FILENAME);
|
_printertype = fileprinter;
|
||||||
break;
|
_printerfile = mask.get (MSK_FILENAME);
|
||||||
case 2: // video
|
break;
|
||||||
_printertype = screenvis;
|
case 2: // video
|
||||||
break;
|
_printertype = screenvis; break;
|
||||||
|
default: // stampante
|
||||||
|
_printertype = winprinter; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fontname = mask.get(MSK_FONT);
|
||||||
|
|
||||||
|
const int cs = mask.get_int(MSK_SIZE);
|
||||||
|
if (cs > 4) _ch_size = cs;
|
||||||
|
|
||||||
|
_lines_per_inch = mask.get_int (MSK_LINES);
|
||||||
|
_isgraphics = mask.get_bool (MSK_ISGRAPHICS);
|
||||||
|
init_formlen ();
|
||||||
|
|
||||||
|
if (k == K_INS)
|
||||||
|
save_configuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
_fontname = mask.get(MSK_FONT);
|
|
||||||
|
|
||||||
const int cs = mask.get_int(MSK_SIZE);
|
|
||||||
if (cs > 4) _ch_size = cs;
|
|
||||||
|
|
||||||
_lines_per_inch = mask.get_int (MSK_LINES);
|
|
||||||
_isgraphics = mask.get_bool (MSK_ISGRAPHICS);
|
|
||||||
init_formlen ();
|
|
||||||
|
|
||||||
if (k == K_INS)
|
|
||||||
save_configuration();
|
|
||||||
|
|
||||||
main_app().enable_menu_item (M_FILE_PG_SETUP);
|
main_app().enable_menu_item (M_FILE_PG_SETUP);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1780,7 +1849,7 @@ void TPrinter::close ()
|
|||||||
{
|
{
|
||||||
if (_exportfile.not_empty() && _txt.lines() > 0L)
|
if (_exportfile.not_empty() && _txt.lines() > 0L)
|
||||||
{
|
{
|
||||||
ofstream txt((const char*)_exportfile);
|
ofstream txt(_exportfile);
|
||||||
for (long i = 0; i < _txt.lines(); i++)
|
for (long i = 0; i < _txt.lines(); i++)
|
||||||
txt << _txt.line_formatted(i) << '\n';
|
txt << _txt.line_formatted(i) << '\n';
|
||||||
txt.close();
|
txt.close();
|
||||||
@ -1789,20 +1858,20 @@ void TPrinter::close ()
|
|||||||
else if (_printertype == winprinter && _txt.lines() > 0L)
|
else if (_printertype == winprinter && _txt.lines() > 0L)
|
||||||
{
|
{
|
||||||
print_txt(_txt);
|
print_txt(_txt);
|
||||||
xvt_print_set_default_device(_defPrinter);
|
// xvt_print_set_default_device(_defPrinter);
|
||||||
}
|
}
|
||||||
else if (_printertype == fileprinter)
|
else if (_printertype == fileprinter)
|
||||||
{
|
{
|
||||||
FILE* fp = fopen(_printerfile, _appendfile ? "a" : "w");
|
FILE* fp = fopen(_printerfile, _appendfile ? "a" : "w");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
{
|
{
|
||||||
error_box("Impossibile aprire il file %s", (const char*)_printerfile);
|
error_box(FR("Impossibile aprire il file %s"), (const char*)_printerfile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (long i = 0; i < _txt.lines(); i++)
|
for (long i = 0; i < _txt.lines(); i++)
|
||||||
fprintf(fp,"%s\n", _txt.line(i));
|
fprintf(fp,"%s\n", _txt.line(i));
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
message_box("Stampa su file terminata. Nome archivio: %s",(const char *)_printerfile);
|
message_box(FR("Stampa su file terminata. Nome archivio: %s"),(const char *)_printerfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_finker)
|
if (_finker)
|
||||||
@ -1957,12 +2026,10 @@ HIDDEN BOOLEAN calc_font_callback(long data)
|
|||||||
return win != NULL_WIN;
|
return win != NULL_WIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
HIDDEN
|
HIDDEN BOOLEAN calc_cols_callback(long data)
|
||||||
BOOLEAN calc_cols_callback(long data)
|
|
||||||
{
|
{
|
||||||
int &numcols=*(int *)data;
|
int &numcols=*(int *)data;
|
||||||
|
|
||||||
|
|
||||||
// Create print window
|
// Create print window
|
||||||
WINDOW win = xvt_print_create_win(printer().get_printrcd(), "Calcolo numero colonne");
|
WINDOW win = xvt_print_create_win(printer().get_printrcd(), "Calcolo numero colonne");
|
||||||
|
|
||||||
|
@ -34,14 +34,11 @@ enum TPrintstyle
|
|||||||
// @enum TPrtype | Indica il tipo di stampante da utilizzare per la stampa
|
// @enum TPrtype | Indica il tipo di stampante da utilizzare per la stampa
|
||||||
enum TPrtype
|
enum TPrtype
|
||||||
{
|
{
|
||||||
normprinter = 0, // @emem Stampa su stampante normale
|
winprinter = 0, // @emem Stampa su stampante normale
|
||||||
fileprinter = 1, // @emem Stampa su file
|
fileprinter = 1, // @emem Stampa su file
|
||||||
spoolprinter = 2, // @emem Stampa utilizzando lo spool
|
screenvis = 2, // @emem Anteprima a video
|
||||||
localprinter = 3, // @emem Stampa su la stampante locale
|
export = 3 // @emem Esporatzione di stampa
|
||||||
screenvis = 4, // @emem Anteprima a video
|
};
|
||||||
winprinter = 5, // @emem Stampa su stampante definita da Windows<tm>
|
|
||||||
export = 6 // @emem Esporatzione di stampa
|
|
||||||
};
|
|
||||||
|
|
||||||
// @doc EXTERNAL
|
// @doc EXTERNAL
|
||||||
|
|
||||||
@ -190,6 +187,8 @@ class TPrinter : public TObject
|
|||||||
|
|
||||||
// @access:(INTERNAL) Private Member
|
// @access:(INTERNAL) Private Member
|
||||||
{
|
{
|
||||||
|
friend class TPrinter_setup_mask;
|
||||||
|
|
||||||
// @cmember:(INTERNAL) Puntatore al file di configurazione
|
// @cmember:(INTERNAL) Puntatore al file di configurazione
|
||||||
FILE* _cnfptr;
|
FILE* _cnfptr;
|
||||||
// @cmember:(INTERNAL) Puntatore al file della stampante
|
// @cmember:(INTERNAL) Puntatore al file della stampante
|
||||||
@ -530,8 +529,9 @@ public:
|
|||||||
void set_printtype(TPrtype dest)
|
void set_printtype(TPrtype dest)
|
||||||
{ _printertype=dest; }
|
{ _printertype=dest; }
|
||||||
// @cmember Setta il nome del file per la stampa su disco
|
// @cmember Setta il nome del file per la stampa su disco
|
||||||
void set_printerfile(const char * ffile)
|
void set_printerfile(const char* ffile)
|
||||||
{ _printerfile=ffile; }
|
{ _printerfile=ffile; }
|
||||||
|
const TFilename& get_printerfile() const { return _printerfile; }
|
||||||
// @cmember Setta il flag per la stampa in coda al file su disco
|
// @cmember Setta il flag per la stampa in coda al file su disco
|
||||||
void set_append(const bool append = TRUE)
|
void set_append(const bool append = TRUE)
|
||||||
{ _appendfile = append; }
|
{ _appendfile = append; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user