Modifiche dalla versione Linux sulla 2.1. Attenzione le modifche devono riguardare solo Linux
git-svn-id: svn://10.65.10.50/trunk@12006 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
06466cea9e
commit
f92a348dd0
@ -27,6 +27,7 @@ extern "C" {
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include "oslinux.h"
|
||||
#include <wx/generic/dcpsg.h>
|
||||
#endif
|
||||
|
||||
#define CAST_WIN(win,w) XVT_ASSERT(win != NULL_WIN); wxWindow& w = *(wxWindow*)win
|
||||
@ -368,6 +369,13 @@ bool TDC::FontChanged() const
|
||||
return _font != _real_font;
|
||||
}
|
||||
|
||||
#ifdef LINUX
|
||||
bool is_printer_dc(wxDC * dc)
|
||||
{
|
||||
return dc->IsKindOf(CLASSINFO(wxPostScriptDC));
|
||||
}
|
||||
#endif
|
||||
|
||||
wxDC& TDC::GetDC(bool bPaint)
|
||||
{
|
||||
if (bPaint)
|
||||
@ -405,6 +413,10 @@ wxDC& TDC::GetDC(bool bPaint)
|
||||
|
||||
if (_dirty < 0 || _dct.mode != _real_dct.mode)
|
||||
{
|
||||
#ifdef LINUX
|
||||
if(!is_printer_dc(_dc))
|
||||
#endif
|
||||
{
|
||||
switch(_dct.mode)
|
||||
{
|
||||
case M_COPY: _dc->SetLogicalFunction(wxCOPY); break;
|
||||
@ -417,6 +429,7 @@ wxDC& TDC::GetDC(bool bPaint)
|
||||
case M_NOT_CLEAR:
|
||||
default: SORRY_BOX();
|
||||
}
|
||||
}
|
||||
_real_dct.mode = _dct.mode;
|
||||
}
|
||||
|
||||
@ -598,7 +611,13 @@ bool TDCMapper::HasValidDC(WINDOW owner) const
|
||||
|
||||
class TwxWindowBase : public wxWindow
|
||||
{
|
||||
#ifdef LINUX
|
||||
wxString Title;
|
||||
#endif
|
||||
public:
|
||||
#ifdef LINUX
|
||||
wxString & GetTitle() {return Title;}
|
||||
#endif
|
||||
TwxWindowBase() { }
|
||||
TwxWindowBase(wxWindow *parent, wxWindowID id, const wxString &title,
|
||||
const wxPoint & pos, const wxSize & size, long style);
|
||||
@ -613,6 +632,9 @@ TwxWindowBase::TwxWindowBase(wxWindow *parent, wxWindowID id, const wxString &ti
|
||||
: wxWindow(parent, id, pos, size, style)
|
||||
{
|
||||
SetTitle(title);
|
||||
#ifdef LINUX
|
||||
Title = title;
|
||||
#endif
|
||||
}
|
||||
|
||||
class TwxWindow : public TwxWindowBase
|
||||
@ -819,6 +841,12 @@ void TwxWindow::OnKeyDown(wxKeyEvent& event)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (event.AltDown() || event.ControlDown())
|
||||
{
|
||||
OnChar(event);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
event.Skip();
|
||||
}
|
||||
@ -1921,6 +1949,10 @@ wxFont& TFontId::Font(wxDC* dc, WINDOW win) const
|
||||
if (nBest == 0)
|
||||
nBest = nMax;
|
||||
dPrintScale = double(nBest) / double(nSize);
|
||||
#ifdef LINUX
|
||||
if (is_printer_dc(dc))
|
||||
dPrintScale *= 0.1; // * wxPostScriptDC::GetResolution()) / 72.0);
|
||||
#endif
|
||||
lastDC = dc;
|
||||
}
|
||||
nSize = (int)(nSize * dPrintScale + 0.5);
|
||||
@ -1991,13 +2023,14 @@ static wxRect ComputeRect(const wxRect& rct, int h, int v, int k)
|
||||
static void DrawImageOnDC(wxDC& dc, TXVT_IMAGE* image, const wxRect& dst, const wxRect& src)
|
||||
{
|
||||
const wxBitmap& bmp = image->Bitmap();
|
||||
|
||||
#ifdef WIN32
|
||||
if (src.GetPosition() == wxPoint(0,0) && src.GetSize() == dst.GetSize() && bmp.Ok())
|
||||
{
|
||||
dc.DrawBitmap(bmp, dst.GetPosition());
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef WIN32
|
||||
if (!OsWin32_DrawBitmap(bmp, dc, dst, src))
|
||||
{
|
||||
const int k = 4;
|
||||
@ -2013,13 +2046,23 @@ static void DrawImageOnDC(wxDC& dc, TXVT_IMAGE* image, const wxRect& dst, const
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
const wxImage& img = (((TXVT_IMAGE*)image)->Image());
|
||||
wxImage sub = img.GetSubImage(src);
|
||||
sub.Rescale(dst.width, dst.height);
|
||||
dc.DrawBitmap(sub.ConvertToBitmap(), dst.GetPosition());
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
const bool printing = is_printer_dc(&dc);
|
||||
|
||||
if (src.GetPosition() == wxPoint(0,0) && src.GetSize() == dst.GetSize() && bmp.Ok())
|
||||
dc.DrawBitmap(bmp, dst.GetX(), dst.GetY(), !printing);
|
||||
else
|
||||
{
|
||||
wxImage img = image->Image().GetSubImage(src);
|
||||
|
||||
if (dst.GetHeight() < src.GetHeight() ||
|
||||
dst.GetWidth() < src.GetWidth())
|
||||
img.Rescale(dst.GetWidth() * 4, dst.GetHeight() * 4);
|
||||
img.Rescale(dst.GetWidth(), dst.GetHeight());
|
||||
dc.DrawBitmap(img.ConvertToBitmap(), dst.GetX(), dst.GetY(), !printing);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, RCT* dest, RCT* source)
|
||||
@ -2699,7 +2742,11 @@ SLIST xvt_fsys_list_files(char *type, char *pat, BOOLEAN dirs)
|
||||
wxString f = ::wxFindFirstFile(pat, flags);
|
||||
while (!f.IsEmpty())
|
||||
{
|
||||
#ifdef WIN32
|
||||
if (f.StartsWith(".\\"))
|
||||
#else
|
||||
if (f.StartsWith("./"))
|
||||
#endif
|
||||
f = f.Mid(2);
|
||||
xvt_slist_add_at_elt(list, NULL, f, 0L);
|
||||
|
||||
@ -2829,7 +2876,20 @@ COLOR xvt_image_get_pixel(XVT_IMAGE image, short x, short y)
|
||||
XVT_IMAGE xvt_image_read(const char* filenamep)
|
||||
{
|
||||
TXVT_IMAGE* i = NULL;
|
||||
#ifdef WIN32
|
||||
const wxString name = filenamep;
|
||||
#else
|
||||
wxString name = "";
|
||||
if (isalpha(filenamep[0u]))
|
||||
{
|
||||
DIRECTORY dirp;
|
||||
|
||||
xvt_fsys_get_dir(&dirp);
|
||||
name = dirp.path;
|
||||
name += "/";
|
||||
}
|
||||
name += filenamep;
|
||||
#endif
|
||||
if (::wxFileExists(name))
|
||||
{
|
||||
i = new TXVT_IMAGE;
|
||||
@ -2890,29 +2950,18 @@ void xvt_image_set_pixel(XVT_IMAGE image, short x, short y, COLOR color)
|
||||
|
||||
void xvt_image_transfer(XVT_IMAGE dstimage, XVT_IMAGE srcimage, RCT *dstrctp, RCT *srcrctp)
|
||||
{
|
||||
#ifdef WIN32
|
||||
wxImage& dst = ((TXVT_IMAGE*)dstimage)->Image();
|
||||
#endif
|
||||
const wxRect rctDst = NormalizeRCT(dstrctp);
|
||||
const wxRect rctSrc = NormalizeRCT(srcrctp);
|
||||
#if 0
|
||||
// Vecchio modo obsoleto e meno potente
|
||||
const wxImage& src = ((const TXVT_IMAGE*)srcimage)->Image();
|
||||
wxImage sub = src.GetSubImage(rctSrc);
|
||||
sub.Rescale(rctDst.width, rctDst.height);
|
||||
if (rctDst.x == 0 && rctDst.y == 0)
|
||||
dst = sub;
|
||||
else
|
||||
SORRY_BOX();
|
||||
#else
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject( ((TXVT_IMAGE*)dstimage)->Bitmap() );
|
||||
DrawImageOnDC(dc, (TXVT_IMAGE*)srcimage, rctDst, rctSrc);
|
||||
#ifdef WIN32
|
||||
dst = dc.GetSelectedBitmap();
|
||||
#endif
|
||||
// #ifdef WIN32
|
||||
// dst = dc.GetSelectedBitmap();
|
||||
// #else
|
||||
dst = ((TXVT_IMAGE*)dstimage)->Bitmap();
|
||||
// #endif
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
#endif
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -3927,7 +3976,7 @@ int xvt_sys_get_os_version()
|
||||
break;
|
||||
#else
|
||||
case wxGTK:
|
||||
os = XVT_WS_LINUX_GTK; break;
|
||||
os = XVT_WS_LINUX; break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
@ -4385,7 +4434,7 @@ WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WIN
|
||||
#ifdef WIN32
|
||||
OsWin32_SetCaptionStyle(w->GetHWND(), wtype == W_DOC);
|
||||
#else
|
||||
OsLinux_SetCaptionStyle((wxWindow*)w, wtype == W_DOC);
|
||||
OsLinux_SetCaptionStyle((wxWindow*)w, style);
|
||||
#endif
|
||||
|
||||
if (menu_rid > 0 && menu_rid != 8000) // 8000 = NULL_MENU_RID
|
||||
|
@ -19,7 +19,26 @@ struct TPRINT_RCD : public PRINT_RCD
|
||||
unsigned char m_data[16*1024];
|
||||
unsigned int m_size; // Dimensione della struct DEVMODE
|
||||
|
||||
void SetData(void* data, unsigned int nSize);
|
||||
#ifdef WIN32
|
||||
void SetData(void * data, unsigned int nSize);
|
||||
#else
|
||||
unsigned int GetSize() {return m_size;}
|
||||
void SetBoolElement(bool v, unsigned int * nSize);
|
||||
void SetUnsignedElement(unsigned char v, unsigned int * nSize);
|
||||
void SetIntElement(int v, unsigned int * nSize);
|
||||
void SetLongElement(long v, unsigned int * nSize);
|
||||
void SetDoubleElement(double v, unsigned int * nSize);
|
||||
void SetStringElement(const char * p, unsigned int * nSize);
|
||||
void SetData(wxPrintData & data);
|
||||
|
||||
bool GetBoolElement(unsigned int * nPos) const ;
|
||||
unsigned char GetUnsignedElement(unsigned int * nPos) const ;
|
||||
int GetIntElement(unsigned int * nPos) const ;
|
||||
long GetLongElement(unsigned int * nPos) const ;
|
||||
double GetDoubleElement(unsigned int * nPos) const ;
|
||||
const char * GetStringElement(unsigned int * nPos) const ;
|
||||
void GetData(wxPrintData & data) const ;
|
||||
#endif
|
||||
TPRINT_RCD();
|
||||
~TPRINT_RCD();
|
||||
};
|
||||
@ -27,6 +46,8 @@ struct TPRINT_RCD : public PRINT_RCD
|
||||
#pragma pack()
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
void TPRINT_RCD::SetData(void* data, unsigned int nSize)
|
||||
{
|
||||
if (nSize <= sizeof(m_data))
|
||||
@ -38,6 +59,177 @@ void TPRINT_RCD::SetData(void* data, unsigned int nSize)
|
||||
xvt_dm_post_error("Printer info exceeds 16K");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void TPRINT_RCD::SetBoolElement(bool v, unsigned int * nSize)
|
||||
{
|
||||
if (*nSize < sizeof(m_data))
|
||||
m_data[(*nSize)++] = (unsigned char) v;
|
||||
else
|
||||
xvt_dm_post_error("Printer info exceeds 16K");
|
||||
}
|
||||
|
||||
void TPRINT_RCD::SetUnsignedElement(unsigned char v, unsigned int * nSize)
|
||||
{
|
||||
if (*nSize < sizeof(m_data))
|
||||
m_data[(*nSize)++] = v;
|
||||
else
|
||||
xvt_dm_post_error("Printer info exceeds 16K");
|
||||
}
|
||||
|
||||
void TPRINT_RCD::SetIntElement(int v, unsigned int * nSize)
|
||||
{
|
||||
if (*nSize + sizeof(int) <= sizeof(m_data))
|
||||
{
|
||||
memcpy(&m_data[*nSize], (void *) &v, sizeof(int));
|
||||
*nSize += sizeof(int);
|
||||
}
|
||||
else
|
||||
xvt_dm_post_error("Printer info exceeds 16K");
|
||||
}
|
||||
|
||||
void TPRINT_RCD::SetLongElement(long v, unsigned int * nSize)
|
||||
{
|
||||
if (*nSize + sizeof(long) <= sizeof(m_data))
|
||||
{
|
||||
memcpy(&m_data[*nSize], (void *) &v, sizeof(long));
|
||||
*nSize += sizeof(long);
|
||||
}
|
||||
else
|
||||
xvt_dm_post_error("Printer info exceeds 16K");
|
||||
}
|
||||
|
||||
void TPRINT_RCD::SetDoubleElement(double v, unsigned int * nSize)
|
||||
{
|
||||
if (*nSize + sizeof(double) <= sizeof(m_data))
|
||||
{
|
||||
memcpy(&m_data[*nSize], (void *) &v, sizeof(double));
|
||||
*nSize += sizeof(double);
|
||||
}
|
||||
else
|
||||
xvt_dm_post_error("Printer info exceeds 16K");
|
||||
}
|
||||
|
||||
void TPRINT_RCD::SetStringElement(const char * p, unsigned int *nSize)
|
||||
{
|
||||
if (*nSize + strlen(p) + 1<= sizeof(m_data))
|
||||
{
|
||||
strcpy((char *) &m_data[*nSize], p);
|
||||
*nSize += strlen(p);
|
||||
m_data[(*nSize)++] = '\0';
|
||||
}
|
||||
else
|
||||
xvt_dm_post_error("Printer info exceeds 16K");
|
||||
}
|
||||
|
||||
void TPRINT_RCD::SetData(wxPrintData & data)
|
||||
{
|
||||
m_size = 0;
|
||||
|
||||
|
||||
SetBoolElement(data.GetCollate(), &m_size);
|
||||
SetBoolElement(data.GetColour(), &m_size);
|
||||
SetUnsignedElement(data.GetDuplex(), &m_size);
|
||||
SetIntElement(data.GetNoCopies(), &m_size);
|
||||
SetIntElement(data.GetOrientation(), &m_size);
|
||||
SetUnsignedElement(data.GetPaperId(), &m_size);
|
||||
SetStringElement((const char *) data.GetPrinterName(), &m_size);
|
||||
SetUnsignedElement(data.GetQuality(), &m_size);
|
||||
|
||||
// PostScript Members
|
||||
SetStringElement((const char *) data.GetPrinterCommand(), &m_size);
|
||||
|
||||
wxString Options = data.GetPrinterOptions();
|
||||
|
||||
if (Options.IsEmpty())
|
||||
Options = "-P" + data.GetPrinterName();
|
||||
SetStringElement((const char *) Options, &m_size);
|
||||
SetStringElement((const char *) data.GetPreviewCommand(), &m_size);
|
||||
SetStringElement((const char *) data.GetFilename(), &m_size);
|
||||
SetStringElement((const char *) data.GetFontMetricPath(), &m_size);
|
||||
SetDoubleElement(data.GetPrinterScaleX(), &m_size);
|
||||
SetDoubleElement(data.GetPrinterScaleY(), &m_size);
|
||||
SetLongElement(data.GetPrinterTranslateX(), &m_size);
|
||||
SetLongElement(data.GetPrinterTranslateY(), &m_size);
|
||||
SetUnsignedElement(wxPRINT_MODE_PRINTER, &m_size);
|
||||
}
|
||||
|
||||
bool TPRINT_RCD::GetBoolElement(unsigned int * nPos) const
|
||||
{
|
||||
bool * p = (bool *) &m_data[*nPos];
|
||||
*nPos += sizeof(bool);
|
||||
return *p;
|
||||
}
|
||||
|
||||
unsigned char TPRINT_RCD::GetUnsignedElement(unsigned int * nPos) const
|
||||
{
|
||||
unsigned char * p = (unsigned char *) &m_data[*nPos];
|
||||
*nPos += sizeof(unsigned char);
|
||||
return *p;
|
||||
}
|
||||
|
||||
int TPRINT_RCD::GetIntElement(unsigned int * nPos) const
|
||||
{
|
||||
int * p = (int *) &m_data[*nPos];
|
||||
*nPos += sizeof(int);
|
||||
return *p;
|
||||
}
|
||||
|
||||
long TPRINT_RCD::GetLongElement(unsigned int * nPos) const
|
||||
{
|
||||
long * p = (long *) &m_data[*nPos];
|
||||
*nPos += sizeof(long);
|
||||
return *p;
|
||||
}
|
||||
|
||||
double TPRINT_RCD::GetDoubleElement(unsigned int * nPos) const
|
||||
{
|
||||
double * p = (double *) &m_data[*nPos];
|
||||
*nPos += sizeof(double);
|
||||
return *p;
|
||||
}
|
||||
|
||||
const char * TPRINT_RCD::GetStringElement(unsigned int * nPos) const
|
||||
{
|
||||
const char * p = (const char *) &m_data[*nPos];
|
||||
*nPos += (strlen(p) +1);
|
||||
return p;
|
||||
}
|
||||
|
||||
void TPRINT_RCD::GetData(wxPrintData & data) const
|
||||
{
|
||||
unsigned int nPos = 0;
|
||||
wxString Str;
|
||||
|
||||
data.SetCollate(GetBoolElement(&nPos));
|
||||
data.SetColour(GetBoolElement(&nPos));
|
||||
data.SetDuplex((wxDuplexMode) GetUnsignedElement(&nPos));
|
||||
data.SetNoCopies(GetIntElement(&nPos));
|
||||
data.SetOrientation(GetIntElement(&nPos));
|
||||
data.SetPaperId((wxPaperSize) GetUnsignedElement(&nPos));
|
||||
Str = GetStringElement(&nPos);
|
||||
data.SetPrinterName(Str);
|
||||
data.SetQuality(GetUnsignedElement(&nPos));
|
||||
|
||||
// PostScript Members
|
||||
Str = GetStringElement(&nPos);
|
||||
data.SetPrinterCommand(Str);
|
||||
Str = GetStringElement(&nPos);
|
||||
data.SetPrinterOptions(Str);
|
||||
Str = GetStringElement(&nPos);
|
||||
data.SetPreviewCommand(Str);
|
||||
Str = GetStringElement(&nPos);
|
||||
data.SetFilename(Str);
|
||||
Str = GetStringElement(&nPos);
|
||||
data.SetFontMetricPath(Str);
|
||||
data.SetPrinterScaleX(GetDoubleElement(&nPos));
|
||||
data.SetPrinterScaleY(GetDoubleElement(&nPos));
|
||||
data.SetPrinterTranslateX(GetLongElement(&nPos));
|
||||
data.SetPrinterTranslateY(GetLongElement(&nPos));
|
||||
data.SetPrintMode((wxPrintMode) GetUnsignedElement(&nPos));
|
||||
}
|
||||
#endif
|
||||
|
||||
TPRINT_RCD::TPRINT_RCD() : m_size(0)
|
||||
{
|
||||
pr = NULL;
|
||||
@ -102,17 +294,19 @@ void TwxPrintOut::InitDC(TPRINT_RCD* prcd)
|
||||
dc = new wxPrinterDC(printer.GetPrintDialogData().GetPrintData());
|
||||
#else
|
||||
dc = new wxPostScriptDC(printer.GetPrintDialogData().GetPrintData());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
wxPrintData data;
|
||||
#ifdef WIN32
|
||||
|
||||
data.SetNativeData(OsWin32_ConvertToNativePrinterInfo(prcd->m_data, prcd->m_size));
|
||||
data.ConvertFromNative();
|
||||
dc = new wxPrinterDC(data);
|
||||
#else
|
||||
dc = new wxPostScriptDC(prcd->m_data);
|
||||
prcd->GetData(data);
|
||||
dc = new wxPostScriptDC(data);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -278,7 +472,7 @@ BOOLEAN xvt_dm_post_page_setup(PRINT_RCD* precp)
|
||||
rcd->SetData(ptr, nSize);
|
||||
delete ptr;
|
||||
#else
|
||||
rcd->SetData((void *) &data, (unsigned int) sizeof(data));
|
||||
rcd->SetData(data);
|
||||
#endif
|
||||
m_PrintoutCache.Reset();
|
||||
}
|
||||
@ -353,12 +547,13 @@ PRINT_RCD* xvt_print_create(int *sizep)
|
||||
delete data;
|
||||
}
|
||||
#else
|
||||
wxPrinter printer;
|
||||
wxPrintData &data = printer.GetPrintDialogData().GetPrintData();
|
||||
wxPrintData data;
|
||||
|
||||
data.SetPrinterName(""); //verificare
|
||||
data.SetPrinterName("");
|
||||
pr = new TPRINT_RCD;
|
||||
pr->SetData((void *) &data, (unsigned int) sizeof(data));
|
||||
pr->SetData(data);
|
||||
*sizep = pr->GetSize();
|
||||
|
||||
#endif
|
||||
|
||||
return pr;
|
||||
@ -380,13 +575,12 @@ PRINT_RCD* xvt_print_create_by_name(int* sizep, const char* name)
|
||||
delete data;
|
||||
}
|
||||
#else
|
||||
wxPrinter printer;
|
||||
wxPrintData &data = printer.GetPrintDialogData().GetPrintData();
|
||||
wxString PrinterName(name);
|
||||
wxPrintData data;
|
||||
|
||||
data.SetPrinterName(PrinterName); //verificare
|
||||
data.SetPrinterName(name);
|
||||
pr = new TPRINT_RCD;
|
||||
pr->SetData((void *) &data, (unsigned int) sizeof(data));
|
||||
pr->SetData(data);
|
||||
*sizep = pr->GetSize();
|
||||
#endif
|
||||
|
||||
return pr;
|
||||
@ -434,11 +628,15 @@ BOOLEAN xvt_print_is_valid(PRINT_RCD* precp)
|
||||
BOOLEAN ok = precp != NULL && precp->pr == NULL;
|
||||
if (ok)
|
||||
{
|
||||
#ifdef WIN32
|
||||
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
|
||||
|
||||
#ifdef WIN32
|
||||
ok = OsWin32_CheckPrinterInfo(rcd->m_data, rcd->m_size);
|
||||
#else
|
||||
// verificare (c'e' da fare qualcosa ?)
|
||||
wxPrintData data;
|
||||
|
||||
rcd->GetData(data);
|
||||
data.Ok();
|
||||
#endif
|
||||
}
|
||||
return ok;
|
||||
@ -463,15 +661,19 @@ int xvt_print_get_name(PRINT_RCD* precp, char* name, int sz_s)
|
||||
}
|
||||
xvt_slist_destroy(plist);
|
||||
}
|
||||
#else
|
||||
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
|
||||
wxPrintData data;
|
||||
|
||||
rcd->GetData(data);
|
||||
wxString n = data.GetPrinterName();
|
||||
#endif
|
||||
if (name != NULL && sz_s > 0)
|
||||
{
|
||||
strncpy(name, n, sz_s);
|
||||
name[sz_s-1] = '\0';
|
||||
}
|
||||
return n.Length();
|
||||
#else
|
||||
return 0; // TBI
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOLEAN xvt_print_open(void)
|
||||
@ -563,13 +765,18 @@ BOOLEAN xvt_print_open_page(PRINT_RCD* precp)
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef LINUX
|
||||
static const char * cups_file = "/etc/cups/printers.conf";
|
||||
static const char * cups_local_file = "./printers.conf";
|
||||
static const char * prcap_local_file = "./printcap";
|
||||
|
||||
static bool is_cups()
|
||||
{
|
||||
static int printer_system = -1;
|
||||
|
||||
if (printer_system < 0)
|
||||
printer_system = xvt_fsys_file_exists("/etc/cups/printer.conf") ? 1 : 2;
|
||||
return (printer_system == 1);
|
||||
printer_system = xvt_fsys_file_exists(cups_file) ? 1 : 2;
|
||||
|
||||
return printer_system == 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -591,38 +798,37 @@ SLIST xvt_print_list_devices()
|
||||
#else
|
||||
if (is_cups())
|
||||
{
|
||||
ifstream p("/etc/cups/printer.conf"); // vedere
|
||||
ifstream p(cups_local_file);
|
||||
char line[4096];
|
||||
|
||||
const char * str_to_find = "Printer";
|
||||
|
||||
while (p.getline(line, sizeof(line)))
|
||||
{
|
||||
if (line[0] == '<')
|
||||
char * s;
|
||||
|
||||
if (line[0] == '<' && line[1] != '/' &&
|
||||
(s = strstr(line, str_to_find)) != NULL)
|
||||
{
|
||||
char * s = strstr(line, "Printer") ;
|
||||
s += strlen(str_to_find);
|
||||
|
||||
if (s != NULL)
|
||||
while (isspace(*s))
|
||||
s++;
|
||||
|
||||
if (*s)
|
||||
{
|
||||
s += 7;
|
||||
char * l = s + strlen(s) - 1;
|
||||
|
||||
while (isspace(*s))
|
||||
s++;
|
||||
|
||||
if (*s)
|
||||
{
|
||||
char * l = s + strlen(s) - 1;
|
||||
|
||||
while (isspace(*l))
|
||||
while (*l == '>' || isspace(*l))
|
||||
l--;
|
||||
*(l + 1) = '\0';
|
||||
xvt_slist_add_at_elt(list, NULL, s, 0L);
|
||||
}
|
||||
*(l + 1) = '\0';
|
||||
xvt_slist_add_at_elt(list, NULL, s, 0L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ifstream p("/etc/printcap"); // vedere
|
||||
ifstream p(prcap_local_file); // vedere
|
||||
char line[4096];
|
||||
|
||||
while (p.getline(line, sizeof(line)))
|
||||
@ -644,8 +850,6 @@ SLIST xvt_print_list_devices()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
return list;
|
||||
}
|
||||
@ -665,8 +869,6 @@ BOOLEAN xvt_print_set_default_device(const char* name)
|
||||
}
|
||||
ok = ::WriteProfileString("windows", "device", pdev) != 0;
|
||||
}
|
||||
#else
|
||||
SORRY_BOX(); //verificare
|
||||
#endif
|
||||
return ok;
|
||||
}
|
||||
@ -680,33 +882,31 @@ BOOLEAN xvt_print_get_default_device(char* name, int namesize)
|
||||
*name = '\0';
|
||||
if (is_cups())
|
||||
{
|
||||
ifstream p("/etc/cups/printer.conf"); // vedere
|
||||
ifstream p(cups_local_file);
|
||||
char line[4096];
|
||||
const char * str_to_find = "<DefaultPrinter";
|
||||
|
||||
while (p.getline(line, sizeof(line)))
|
||||
{
|
||||
if (line[0] == '<')
|
||||
char * s = strstr(line, str_to_find) ;
|
||||
|
||||
if (s != NULL)
|
||||
{
|
||||
char * s = strstr(line, "ltPrinter") ;
|
||||
s += strlen(str_to_find);
|
||||
|
||||
if (s != NULL)
|
||||
while (isspace(*s))
|
||||
s++;
|
||||
|
||||
if (*s)
|
||||
{
|
||||
s += 9;
|
||||
char * l = s + strlen(s) - 1;
|
||||
|
||||
while (isspace(*s))
|
||||
s++;
|
||||
|
||||
if (*s)
|
||||
{
|
||||
char * l = s + strlen(s) - 1;
|
||||
|
||||
while (isspace(*l))
|
||||
l--;
|
||||
*(l + 1) = '\0';
|
||||
strcpy(name, s);
|
||||
}
|
||||
ok = TRUE;
|
||||
while (*l == '>' || isspace(*l))
|
||||
l--;
|
||||
*(l + 1) = '\0';
|
||||
strcpy(name, s);
|
||||
}
|
||||
ok = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user