2002-02-28 14:26:23 +00:00
|
|
|
#include "wxinc.h"
|
|
|
|
#include "wx/print.h"
|
|
|
|
#include "wx/printdlg.h"
|
|
|
|
|
|
|
|
#include "xvt.h"
|
2005-09-23 15:55:44 +00:00
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
#ifdef WIN32
|
2004-04-28 09:49:37 +00:00
|
|
|
#include "wx/dcps.h"
|
2005-09-23 15:55:44 +00:00
|
|
|
#include "wx/msw/printdlg.h"
|
2002-02-28 14:26:23 +00:00
|
|
|
#include "oswin32.h"
|
2003-05-22 15:25:25 +00:00
|
|
|
#else
|
2005-09-23 15:55:44 +00:00
|
|
|
#include "wx/setup.h"
|
|
|
|
#include "wx/dcps.h"
|
2003-05-22 15:25:25 +00:00
|
|
|
#include "oslinux.h"
|
2004-03-12 14:21:37 +00:00
|
|
|
#include "incstr.h"
|
2003-05-22 15:25:25 +00:00
|
|
|
#endif
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
#include "xvintern.h"
|
2006-07-11 13:10:51 +00:00
|
|
|
#include "xvtpdf.h"
|
2002-02-28 14:26:23 +00:00
|
|
|
|
2002-07-03 14:53:33 +00:00
|
|
|
#pragma pack(4)
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
struct TPRINT_RCD : public PRINT_RCD
|
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
#ifdef WIN32
|
2002-07-03 14:53:33 +00:00
|
|
|
unsigned char m_data[16*1024];
|
|
|
|
unsigned int m_size; // Dimensione della struct DEVMODE
|
2002-02-28 14:26:23 +00:00
|
|
|
|
2004-04-27 19:09:18 +00:00
|
|
|
void SetData(void * data, unsigned int nSize);
|
|
|
|
#else
|
2005-09-23 15:55:44 +00:00
|
|
|
wxPrintNativeDataBase * m_data;
|
|
|
|
unsigned int m_size; // Dimensione di wxPostScriptPrintNativeData
|
|
|
|
|
|
|
|
void GetData(wxPrintNativeDataBase * data) const;
|
|
|
|
void SetData(void * data);
|
2006-04-13 17:56:02 +00:00
|
|
|
|
2006-07-11 13:10:51 +00:00
|
|
|
|
2004-04-27 19:09:18 +00:00
|
|
|
#endif
|
2005-09-23 15:55:44 +00:00
|
|
|
|
|
|
|
unsigned int GetSize() const { return m_size; }
|
|
|
|
|
2002-07-03 14:53:33 +00:00
|
|
|
TPRINT_RCD();
|
|
|
|
~TPRINT_RCD();
|
2002-02-28 14:26:23 +00:00
|
|
|
};
|
|
|
|
|
2002-07-03 14:53:33 +00:00
|
|
|
#pragma pack()
|
|
|
|
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
#ifdef WIN32
|
2002-07-03 14:53:33 +00:00
|
|
|
void TPRINT_RCD::SetData(void* data, unsigned int nSize)
|
|
|
|
{
|
|
|
|
if (nSize <= sizeof(m_data))
|
|
|
|
{
|
|
|
|
memcpy(m_data, data, nSize);
|
|
|
|
m_size = nSize;
|
|
|
|
}
|
2004-01-22 15:10:39 +00:00
|
|
|
else
|
|
|
|
xvt_dm_post_error("Printer info exceeds 16K");
|
2002-07-03 14:53:33 +00:00
|
|
|
}
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
TPRINT_RCD::TPRINT_RCD() : m_size(0)
|
2004-04-27 19:09:18 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
pr = NULL;
|
|
|
|
memset(m_data, 0, sizeof(m_data));
|
2004-04-27 19:09:18 +00:00
|
|
|
}
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
TPRINT_RCD::~TPRINT_RCD()
|
2004-04-27 19:09:18 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
memset(m_data, 0, sizeof(m_data));
|
2004-04-27 19:09:18 +00:00
|
|
|
m_size = 0;
|
2006-07-11 13:10:51 +00:00
|
|
|
|
2004-04-27 19:09:18 +00:00
|
|
|
}
|
2005-09-23 15:55:44 +00:00
|
|
|
#else
|
|
|
|
void TPRINT_RCD::GetData(wxPrintNativeDataBase * data) const
|
2004-04-27 19:09:18 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
memcpy(data, m_data, GetSize());
|
2004-04-27 19:09:18 +00:00
|
|
|
}
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
void TPRINT_RCD::SetData(void* data)
|
2004-04-27 19:09:18 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
memcpy(m_data, data, GetSize());
|
2004-04-27 19:09:18 +00:00
|
|
|
}
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
wxNativePrintFactory __factory;
|
2004-04-27 19:09:18 +00:00
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
TPRINT_RCD::TPRINT_RCD()
|
2003-05-22 15:25:25 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
m_data = __factory.CreatePrintNativeData();
|
|
|
|
m_size = sizeof(*m_data);
|
2002-07-03 14:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TPRINT_RCD::~TPRINT_RCD()
|
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
delete m_data;
|
2002-07-03 14:53:33 +00:00
|
|
|
}
|
2005-09-23 15:55:44 +00:00
|
|
|
#endif
|
2002-07-03 14:53:33 +00:00
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TwxPrintOut
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TwxPrintOut : public wxPrintout
|
|
|
|
{
|
|
|
|
protected:
|
2005-09-23 15:55:44 +00:00
|
|
|
const TPRINT_RCD* m_prcd;
|
2003-10-27 15:54:53 +00:00
|
|
|
bool m_bBadDriver;
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
virtual bool HasPage(int pageNum);
|
|
|
|
virtual bool OnPrintPage(int pageNum);
|
2003-10-14 13:40:52 +00:00
|
|
|
void ResetDC();
|
2005-09-23 15:55:44 +00:00
|
|
|
#if wxCHECK_VERSION(2,6,1)
|
2006-07-11 14:59:08 +00:00
|
|
|
wxDC* CreateDC(const TPRINT_RCD* prcd, const char* title);
|
2005-09-23 15:55:44 +00:00
|
|
|
#endif
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
public:
|
2003-10-27 15:54:53 +00:00
|
|
|
void SetBadDriver(bool bd) { m_bBadDriver = bd; }
|
|
|
|
bool HasBadDriver() const { return m_bBadDriver; }
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
wxString PrinterName() const;
|
2006-12-13 22:14:29 +00:00
|
|
|
bool IsPDF() const { return !HasBadDriver() && xvt_print_is_pdf((PRINT_RCD *)m_prcd) != 0; }
|
2006-12-13 16:22:33 +00:00
|
|
|
|
2006-07-11 14:59:08 +00:00
|
|
|
void InitDC(const TPRINT_RCD* prcd, const char* title);
|
2005-09-23 15:55:44 +00:00
|
|
|
TwxPrintOut(const TPRINT_RCD* prcd = NULL);
|
2006-07-11 13:10:51 +00:00
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
virtual ~TwxPrintOut() {}
|
2002-02-28 14:26:23 +00:00
|
|
|
};
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
wxString TwxPrintOut::PrinterName() const
|
|
|
|
{
|
|
|
|
char strName[MAX_PATH] = "";
|
|
|
|
xvt_print_get_name(m_prcd, strName, sizeof(strName));
|
|
|
|
return strName;
|
|
|
|
}
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
bool TwxPrintOut::HasPage(int pageNum)
|
2003-10-14 13:40:52 +00:00
|
|
|
{ return true; }
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
bool TwxPrintOut::OnPrintPage(int pageNum)
|
2003-10-14 13:40:52 +00:00
|
|
|
{ return false; }
|
2002-02-28 14:26:23 +00:00
|
|
|
|
2003-10-14 13:40:52 +00:00
|
|
|
void TwxPrintOut::ResetDC()
|
2002-02-28 14:26:23 +00:00
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
wxDC* dc = GetDC();
|
2002-02-28 14:26:23 +00:00
|
|
|
if (dc != NULL)
|
2006-10-09 14:45:09 +00:00
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
delete dc;
|
2006-10-09 14:45:09 +00:00
|
|
|
SetDC(NULL);
|
|
|
|
}
|
2003-10-14 13:40:52 +00:00
|
|
|
}
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
#if wxCHECK_VERSION(2,6,1)
|
|
|
|
static void RCD2data(const TPRINT_RCD* prcd, wxPrintData& data)
|
2006-07-11 13:10:51 +00:00
|
|
|
|
2003-10-14 13:40:52 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
wxWindowsPrintNativeData ndb;
|
|
|
|
ndb.SetDevMode(OsWin32_ConvertToNativePrinterInfo((void*)prcd->m_data, prcd->m_size));
|
|
|
|
ndb.TransferTo(data);
|
|
|
|
#else
|
|
|
|
prcd->GetData(data.GetNativeData());
|
|
|
|
data.ConvertFromNative();
|
|
|
|
#endif
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
static void data2RCD(const wxPrintData& data, TPRINT_RCD* prcd)
|
|
|
|
{
|
|
|
|
#ifdef WIN32
|
|
|
|
wxWindowsPrintNativeData* pNative = (wxWindowsPrintNativeData*)data.GetNativeData();
|
|
|
|
unsigned int nSize = 0;
|
|
|
|
void* ptr = OsWin32_ConvertFromNativePrinterInfo(pNative->GetDevMode(), nSize);
|
|
|
|
prcd->SetData(ptr, nSize);
|
|
|
|
delete ptr;
|
|
|
|
#else
|
|
|
|
((wxPrintData&)data).ConvertToNative();
|
|
|
|
prcd->SetData(data.GetNativeData());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2006-07-11 14:59:08 +00:00
|
|
|
wxDC* TwxPrintOut::CreateDC(const TPRINT_RCD* prcd, const char* title)
|
2005-09-23 15:55:44 +00:00
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
m_prcd = prcd;
|
2005-09-23 15:55:44 +00:00
|
|
|
wxDC* dc = NULL;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
if (m_prcd == NULL)
|
|
|
|
{
|
|
|
|
wxPrinter printer;
|
2003-05-22 15:25:25 +00:00
|
|
|
#ifdef WIN32
|
2004-04-28 09:49:37 +00:00
|
|
|
dc = new wxPrinterDC(printer.GetPrintDialogData().GetPrintData());
|
2003-05-22 15:25:25 +00:00
|
|
|
#else
|
2005-09-23 15:55:44 +00:00
|
|
|
dc = new wxPostScriptDC(printer.GetPrintDialogData().GetPrintData());
|
|
|
|
#endif
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
2005-09-23 15:55:44 +00:00
|
|
|
else
|
2002-02-28 14:26:23 +00:00
|
|
|
{
|
|
|
|
wxPrintData data;
|
2006-12-13 16:22:33 +00:00
|
|
|
|
|
|
|
RCD2data(prcd, data);
|
|
|
|
|
|
|
|
const wxString strName = PrinterName();
|
|
|
|
|
2006-04-13 17:56:02 +00:00
|
|
|
data.SetPrinterName(strName);
|
2006-12-13 16:22:33 +00:00
|
|
|
|
|
|
|
const bool ispdf = IsPDF();
|
2006-07-11 14:59:08 +00:00
|
|
|
|
2006-07-11 13:10:51 +00:00
|
|
|
if (ispdf)
|
|
|
|
dc = new TwxPDFDC(data, title);
|
|
|
|
else
|
2006-07-11 14:59:08 +00:00
|
|
|
#ifdef WIN32
|
2006-07-11 13:10:51 +00:00
|
|
|
dc = new wxPrinterDC(data);
|
2003-05-22 15:25:25 +00:00
|
|
|
#else
|
2006-07-11 14:59:08 +00:00
|
|
|
dc = new wxPostScriptDC(data);
|
2003-05-22 15:25:25 +00:00
|
|
|
#endif
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
2006-04-13 17:56:02 +00:00
|
|
|
wxSize s = dc->GetPPI();
|
|
|
|
if (s.x > 0)
|
|
|
|
SetPPIPrinter(s.x, s.y);
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
|
2006-04-13 17:56:02 +00:00
|
|
|
s = dc->GetSize();
|
|
|
|
if (s.x > 0)
|
|
|
|
SetPageSizePixels(s.x, s.y);
|
|
|
|
|
|
|
|
SetDC(dc);
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
wxWindow* pAbort = wxPrinterBase::sm_abortWindow;
|
|
|
|
if (pAbort != NULL)
|
|
|
|
{
|
|
|
|
wxWindow* pStatic = pAbort->FindWindow(wxID_STATIC);
|
|
|
|
if (pStatic != NULL)
|
|
|
|
{
|
|
|
|
wxString strPrompt = wxT("Stampa su ");
|
|
|
|
if (IsPDF())
|
|
|
|
strPrompt += wxT("PDF");
|
|
|
|
else
|
|
|
|
strPrompt += PrinterName();
|
|
|
|
pStatic->SetLabel(strPrompt);
|
|
|
|
}
|
|
|
|
}
|
2005-09-23 15:55:44 +00:00
|
|
|
return dc;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-07-11 14:59:08 +00:00
|
|
|
void TwxPrintOut::InitDC(const TPRINT_RCD* prcd, const char* title)
|
2005-09-23 15:55:44 +00:00
|
|
|
{
|
|
|
|
ResetDC();
|
|
|
|
#if wxCHECK_VERSION(2,6,1)
|
2006-07-11 14:59:08 +00:00
|
|
|
wxDC* dc = CreateDC(prcd, title);
|
2005-09-23 15:55:44 +00:00
|
|
|
#else
|
|
|
|
wxDC* dc = NULL;
|
|
|
|
|
|
|
|
m_prcd = prcd;
|
|
|
|
|
|
|
|
if (m_prcd == NULL)
|
|
|
|
{
|
|
|
|
wxPrinter printer;
|
|
|
|
dc = new wxPrinterDC(printer.GetPrintDialogData().GetPrintData());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxPrintData data;
|
|
|
|
data.SetNativeData(OsWin32_ConvertToNativePrinterInfo((void*)prcd->m_data, prcd->m_size));
|
|
|
|
data.ConvertFromNative();
|
|
|
|
dc = new wxPrinterDC(data);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
wxSize s = dc->GetPPI();
|
2006-07-11 13:10:51 +00:00
|
|
|
if (s.x >0)
|
2006-10-09 14:45:09 +00:00
|
|
|
SetPPIPrinter(s.x, s.y);
|
2006-04-13 17:56:02 +00:00
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
s = dc->GetSize();
|
2006-04-13 17:56:02 +00:00
|
|
|
if (s.x > 0)
|
|
|
|
SetPageSizePixels(s.x, s.y);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
SetDC(dc);
|
|
|
|
}
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
TwxPrintOut::TwxPrintOut(const TPRINT_RCD* prcd)
|
2003-10-27 15:54:53 +00:00
|
|
|
: wxPrintout(_GetAppTitle()), m_bBadDriver(false)
|
2003-05-22 15:25:25 +00:00
|
|
|
{
|
2006-07-11 13:10:51 +00:00
|
|
|
InitDC(prcd, _GetAppTitle());
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
2003-10-14 13:40:52 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TwxPrintOutCache
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TwxPrintOutCache
|
|
|
|
{
|
|
|
|
unsigned long m_signature;
|
|
|
|
TwxPrintOut* m_po;
|
2005-09-23 15:55:44 +00:00
|
|
|
bool m_bLocked;
|
2003-10-14 13:40:52 +00:00
|
|
|
|
|
|
|
protected:
|
2005-09-23 15:55:44 +00:00
|
|
|
unsigned long Signature(const TPRINT_RCD* prcd) const;
|
2003-10-14 13:40:52 +00:00
|
|
|
|
|
|
|
public:
|
2005-09-23 15:55:44 +00:00
|
|
|
TwxPrintOut& Get(const TPRINT_RCD* prcd);
|
2003-10-14 13:40:52 +00:00
|
|
|
void Reset();
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
void Lock() { m_bLocked = true; }
|
|
|
|
void Unlock() { m_bLocked = false; }
|
|
|
|
|
|
|
|
bool Ok() const { return m_po != NULL; }
|
|
|
|
bool Locked() const { return m_bLocked; }
|
|
|
|
bool Printing() const { return Ok() && Locked(); }
|
|
|
|
|
2006-10-09 14:45:09 +00:00
|
|
|
TwxPrintOutCache();
|
|
|
|
~TwxPrintOutCache();
|
2003-10-14 13:40:52 +00:00
|
|
|
} m_PrintoutCache;
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
unsigned long TwxPrintOutCache::Signature(const TPRINT_RCD* prcd) const
|
2003-10-14 13:40:52 +00:00
|
|
|
{
|
2003-10-22 10:56:09 +00:00
|
|
|
unsigned long h = 0;
|
2005-03-03 15:42:04 +00:00
|
|
|
if (prcd != NULL)
|
2003-10-22 10:56:09 +00:00
|
|
|
{
|
2005-03-03 15:42:04 +00:00
|
|
|
const unsigned char* data = (const unsigned char*)prcd;
|
2005-09-23 15:55:44 +00:00
|
|
|
for (size_t c = 0; c < prcd->GetSize(); c++)
|
2005-03-03 15:42:04 +00:00
|
|
|
{
|
|
|
|
h = (h << 2) + data[c];
|
|
|
|
const unsigned long i = h & 0xC0000000;
|
|
|
|
if (i) h = (h ^ (i >> 12)) & 0x3FFFFFFF;
|
|
|
|
}
|
2006-07-11 13:10:51 +00:00
|
|
|
|
2003-10-22 10:56:09 +00:00
|
|
|
}
|
|
|
|
return h;
|
2003-10-14 13:40:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TwxPrintOutCache::Reset()
|
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
wxASSERT(!Locked());
|
2003-10-14 13:40:52 +00:00
|
|
|
if (m_po != NULL)
|
|
|
|
{
|
|
|
|
delete m_po;
|
|
|
|
m_po = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
TwxPrintOut& TwxPrintOutCache::Get(const TPRINT_RCD* prcd)
|
2003-10-14 13:40:52 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
if (!Locked())
|
|
|
|
{
|
|
|
|
if (prcd == NULL)
|
|
|
|
{
|
|
|
|
if (m_po == NULL)
|
|
|
|
m_po = new TwxPrintOut;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned long signature = Signature(prcd);
|
|
|
|
if (m_po != NULL && m_signature == signature)
|
|
|
|
return *m_po;
|
|
|
|
Reset();
|
|
|
|
m_po = new TwxPrintOut(prcd);
|
|
|
|
m_signature = signature;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wxASSERT(m_po != NULL);
|
|
|
|
|
|
|
|
return *m_po;
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
2006-10-09 14:45:09 +00:00
|
|
|
TwxPrintOutCache::TwxPrintOutCache() : m_signature(0), m_po(NULL)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
TwxPrintOutCache::~TwxPrintOutCache()
|
|
|
|
{
|
|
|
|
// Reset(); // Essendo un oggetto statico la delete m_po non funziona!
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TPrintDC
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
2004-06-28 15:24:28 +00:00
|
|
|
// Flag di reset ad inizio pagina
|
|
|
|
bool TPrintDC::_page_start = false;
|
|
|
|
|
|
|
|
void TPrintDC::SetPageStart()
|
|
|
|
{ _page_start = true; }
|
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
wxDC& TPrintDC::GetDC(bool)
|
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
_dc = m_PrintoutCache.Get(NULL).GetDC(); // Forza display context corrente
|
2004-06-28 15:24:28 +00:00
|
|
|
if (_page_start)
|
|
|
|
{
|
|
|
|
_dirty = -1;
|
|
|
|
_page_start = false;
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
return TDC::GetDC(false);
|
|
|
|
}
|
|
|
|
|
2004-03-17 17:15:44 +00:00
|
|
|
void TPrintDC::KillDC()
|
|
|
|
{
|
|
|
|
_dc = NULL; // _dc is owned by wxPrintout
|
|
|
|
}
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
TPrintDC::TPrintDC(wxWindow* owner) : TDC(owner)
|
2004-06-28 15:24:28 +00:00
|
|
|
{
|
|
|
|
_page_start = false;
|
|
|
|
}
|
2002-02-28 14:26:23 +00:00
|
|
|
|
|
|
|
TPrintDC::~TPrintDC()
|
|
|
|
{
|
2004-06-28 15:24:28 +00:00
|
|
|
KillDC();
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Printing management :-(((((
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
BOOLEAN xvt_app_escape(int esc_code, PRINT_RCD* rcd, long* ph, long* pw, long* pvr, long* phr)
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
switch (esc_code)
|
|
|
|
{
|
|
|
|
case XVT_ESC_GET_PRINTER_INFO:
|
2005-05-23 12:17:02 +00:00
|
|
|
*ph = *pw = *pvr = *phr = 0;
|
2003-02-05 14:26:24 +00:00
|
|
|
if (rcd == NULL || xvt_print_is_valid(rcd))
|
2002-02-28 14:26:23 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
const TwxPrintOut& po = m_PrintoutCache.Get((TPRINT_RCD*)rcd);
|
2003-10-14 13:40:52 +00:00
|
|
|
int w, h;
|
2005-09-23 15:55:44 +00:00
|
|
|
po.GetPPIPrinter(&w, &h);
|
|
|
|
*phr = w; *pvr = h;
|
|
|
|
po.GetPageSizePixels(&w, &h);
|
|
|
|
*pw = w; *ph = h;
|
2006-07-11 13:10:51 +00:00
|
|
|
|
2003-02-05 14:26:24 +00:00
|
|
|
return TRUE;
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
2003-02-05 14:26:24 +00:00
|
|
|
break;
|
2005-05-23 12:17:02 +00:00
|
|
|
case XVT_ESC_SET_PRINTER_INFO:
|
2005-09-23 15:55:44 +00:00
|
|
|
if (xvt_print_is_valid(rcd) && ph != NULL && pw != NULL)
|
2005-05-23 12:17:02 +00:00
|
|
|
{
|
|
|
|
wxPrintData data;
|
|
|
|
|
|
|
|
TPRINT_RCD* prcd = (TPRINT_RCD*)rcd;
|
2005-09-23 15:55:44 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#if wxCHECK_VERSION(2,6,1)
|
|
|
|
RCD2data(prcd, data);
|
|
|
|
#else
|
2005-05-23 12:17:02 +00:00
|
|
|
data.SetNativeData(OsWin32_ConvertToNativePrinterInfo(prcd->m_data, prcd->m_size));
|
|
|
|
|
|
|
|
data.ConvertFromNative();
|
2005-09-23 15:55:44 +00:00
|
|
|
#endif
|
2005-05-23 12:17:02 +00:00
|
|
|
data.SetOrientation(*ph > *pw ? 1 : 2);
|
|
|
|
data.ConvertToNative();
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
#if wxCHECK_VERSION(2,6,1)
|
|
|
|
data2RCD(data, prcd);
|
|
|
|
#else
|
2005-05-23 12:17:02 +00:00
|
|
|
void* pHandle = data.GetNativeData();
|
|
|
|
unsigned int nSize = 0;
|
|
|
|
void* ptr = OsWin32_ConvertFromNativePrinterInfo(pHandle, nSize);
|
|
|
|
prcd->SetData(ptr, nSize);
|
|
|
|
delete ptr;
|
|
|
|
#endif
|
2005-09-23 15:55:44 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
RCD2data(prcd, data);
|
|
|
|
data.SetOrientation(*ph > *pw ? 1 : 2);
|
|
|
|
data2RCD(data, prcd);
|
|
|
|
#endif
|
2005-05-23 12:17:02 +00:00
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
return true;
|
2005-05-23 12:17:02 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-07-11 13:10:51 +00:00
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
default:
|
2002-02-28 14:26:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
BOOLEAN xvt_dm_post_page_setup(PRINT_RCD* precp)
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
wxPageSetupDialog dlg((wxWindow*)TASK_WIN);
|
|
|
|
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
|
|
|
|
|
2004-02-13 14:52:01 +00:00
|
|
|
wxPageSetupData& pdd = dlg.GetPageSetupData();
|
|
|
|
wxPrintData& data = pdd.GetPrintData();
|
2003-05-22 15:25:25 +00:00
|
|
|
#ifdef WIN32
|
2005-09-23 15:55:44 +00:00
|
|
|
#if wxCHECK_VERSION(2,6,1)
|
|
|
|
RCD2data(rcd, data);
|
|
|
|
#else
|
2004-02-13 14:52:01 +00:00
|
|
|
void* pHandle = OsWin32_ConvertToNativePrinterInfo(rcd->m_data, rcd->m_size);
|
|
|
|
data.SetNativeData(pHandle);
|
|
|
|
data.ConvertFromNative();
|
2005-09-23 15:55:44 +00:00
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
RCD2data(rcd, data);
|
2003-05-22 15:25:25 +00:00
|
|
|
#endif
|
2004-02-13 14:52:01 +00:00
|
|
|
pdd.EnableMargins(false);
|
2002-02-28 14:26:23 +00:00
|
|
|
|
2004-02-13 14:52:01 +00:00
|
|
|
const BOOLEAN ok = dlg.ShowModal() == wxID_OK;
|
|
|
|
if (ok)
|
2002-02-28 14:26:23 +00:00
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
#ifdef WIN32
|
2005-09-23 15:55:44 +00:00
|
|
|
#if wxCHECK_VERSION(2,6,1)
|
|
|
|
data2RCD(data, rcd);
|
|
|
|
#else
|
2004-02-13 14:52:01 +00:00
|
|
|
pHandle = data.GetNativeData();
|
2002-07-03 14:53:33 +00:00
|
|
|
unsigned int nSize = 0;
|
|
|
|
void* ptr = OsWin32_ConvertFromNativePrinterInfo(pHandle, nSize);
|
|
|
|
rcd->SetData(ptr, nSize);
|
2002-02-28 14:26:23 +00:00
|
|
|
delete ptr;
|
2005-09-23 15:55:44 +00:00
|
|
|
#endif
|
2002-02-28 14:26:23 +00:00
|
|
|
#else
|
2005-09-23 15:55:44 +00:00
|
|
|
RCD2data(rcd, data);
|
2002-02-28 14:26:23 +00:00
|
|
|
#endif
|
2003-10-14 13:40:52 +00:00
|
|
|
m_PrintoutCache.Reset();
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
2004-02-13 14:52:01 +00:00
|
|
|
|
|
|
|
return ok;
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
long xvt_fmap_get_family_sizes(PRINT_RCD *precp, char *family, long *size_array, BOOLEAN *scalable, long max_sizes)
|
|
|
|
{
|
2003-10-27 15:54:53 +00:00
|
|
|
long size = 0;
|
2002-02-28 14:26:23 +00:00
|
|
|
*scalable = FALSE;
|
|
|
|
|
2004-05-20 14:18:12 +00:00
|
|
|
#ifdef WIN32
|
2005-09-23 15:55:44 +00:00
|
|
|
if (xvt_print_is_valid(precp))
|
2002-02-28 14:26:23 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
const TwxPrintOut& po = m_PrintoutCache.Get((TPRINT_RCD*)precp);
|
|
|
|
if (!po.HasBadDriver())
|
2005-09-28 11:51:41 +00:00
|
|
|
size = OsWin32_EnumerateSizes(po.GetDC()->GetHDC(), family, size_array, scalable, max_sizes);
|
2004-05-20 14:18:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
size = OsWin32_EnumerateSizes(NULL, family, size_array, scalable, max_sizes);
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
#else
|
2004-05-20 14:18:12 +00:00
|
|
|
size = OsLinux_EnumerateSizes(family, size_array, scalable, max_sizes);
|
2003-05-22 15:25:25 +00:00
|
|
|
#endif
|
2002-02-28 14:26:23 +00:00
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
return size;
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
long xvt_fmap_get_families(PRINT_RCD *precp, char **family_array, long max_families)
|
|
|
|
{
|
2003-10-22 10:56:09 +00:00
|
|
|
long size = 0;
|
|
|
|
family_array[0] = NULL;
|
2002-02-28 14:26:23 +00:00
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
#ifdef WIN32
|
2005-09-23 15:55:44 +00:00
|
|
|
if (xvt_print_is_valid(precp))
|
2004-05-20 11:07:27 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
TwxPrintOut& po = m_PrintoutCache.Get((TPRINT_RCD*)precp);
|
2005-09-28 11:51:41 +00:00
|
|
|
size = OsWin32_EnumerateFamilies(po.GetDC()->GetHDC(), family_array, max_families);
|
2003-10-23 15:17:33 +00:00
|
|
|
if (size == 0)
|
2005-09-23 15:55:44 +00:00
|
|
|
po.SetBadDriver(true);
|
2004-05-20 11:07:27 +00:00
|
|
|
}
|
|
|
|
else
|
2004-05-20 14:18:12 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
wxFrame* tw = (wxFrame*)TASK_WIN;
|
2004-05-20 14:18:12 +00:00
|
|
|
wxClientDC dc(tw);
|
2005-09-28 11:51:41 +00:00
|
|
|
size = OsWin32_EnumerateFamilies(dc.GetHDC(), family_array, max_families);
|
2004-05-20 14:18:12 +00:00
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
#else
|
2004-05-20 11:07:27 +00:00
|
|
|
size = OsLinux_EnumerateFamilies(family_array, max_families);
|
2003-05-22 15:25:25 +00:00
|
|
|
#endif
|
2004-05-20 11:07:27 +00:00
|
|
|
|
|
|
|
return size;
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
void xvt_print_close(void)
|
|
|
|
{
|
2002-07-03 14:53:33 +00:00
|
|
|
// Nothing to do ?
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
2004-04-28 09:49:37 +00:00
|
|
|
BOOLEAN xvt_print_close_page(PRINT_RCD* precp)
|
2003-05-22 15:25:25 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
BOOLEAN ok = m_PrintoutCache.Printing();
|
|
|
|
if (ok)
|
2004-04-28 09:49:37 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
const TwxPrintOut& po = m_PrintoutCache.Get(NULL);
|
|
|
|
wxDC* dc = po.GetDC();
|
|
|
|
dc->EndPage();
|
2004-04-28 09:49:37 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
TPRINT_RCD* prcd = (TPRINT_RCD*)precp;
|
|
|
|
if (OsWin32_IsGenericTextOnly(prcd->m_data))
|
2005-09-23 15:55:44 +00:00
|
|
|
OsWin32_SpoolNewLine((unsigned int)dc->GetHDC());
|
2004-04-28 09:49:37 +00:00
|
|
|
#endif
|
|
|
|
}
|
2005-09-23 15:55:44 +00:00
|
|
|
return ok;
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
PRINT_RCD* xvt_print_create(int *sizep)
|
|
|
|
{
|
2006-07-11 13:10:51 +00:00
|
|
|
return xvt_print_create_by_name(sizep, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Impone il nome ad un PRINT_RCD.
|
|
|
|
// Utilizzato per la definiz. della stamp. virtuale PDF predefinita
|
|
|
|
int xvt_print_set_name(PRINT_RCD* precp, const char* name)
|
|
|
|
{
|
|
|
|
if (precp == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!name || !*name)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
wxString n = name;
|
2003-02-05 14:26:24 +00:00
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
#ifdef WIN32
|
2006-07-11 13:10:51 +00:00
|
|
|
strncpy(((char*)precp) + 4, name, 32);
|
2003-05-22 15:25:25 +00:00
|
|
|
#else
|
2006-07-11 13:10:51 +00:00
|
|
|
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
|
|
|
|
wxPrintData data;
|
2003-02-05 14:26:24 +00:00
|
|
|
|
2006-07-11 13:10:51 +00:00
|
|
|
rcd->GetData(data);
|
|
|
|
data.SetPrinterName(n);
|
|
|
|
rcd->SetData(data);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return n.Length();
|
2002-07-03 14:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Nuova funzione inventata da Aga
|
2003-05-22 15:25:25 +00:00
|
|
|
PRINT_RCD* xvt_print_create_by_name(int* sizep, const char* name)
|
|
|
|
{
|
2003-02-05 14:26:24 +00:00
|
|
|
TPRINT_RCD* pr = NULL;
|
|
|
|
*sizep = 0;
|
2006-07-11 13:10:51 +00:00
|
|
|
const bool ispdf = (name && *name) && (xvt_str_compare_ignoring_case(name, XVT_PDF_PRINTER_NAME) == 0);
|
|
|
|
|
|
|
|
if (ispdf)
|
|
|
|
name = NULL;
|
2003-02-05 14:26:24 +00:00
|
|
|
|
2002-07-03 14:53:33 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
void* data = OsWin32_GetPrinterInfo(*sizep, name);
|
2003-02-05 14:26:24 +00:00
|
|
|
if (data != NULL)
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
pr = new TPRINT_RCD;
|
2003-02-05 14:26:24 +00:00
|
|
|
pr->SetData(data, *sizep);
|
|
|
|
*sizep += 4; // Spazio per puntatore iniziale
|
|
|
|
delete data;
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
#else
|
2004-04-27 19:09:18 +00:00
|
|
|
wxPrintData data;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
2006-07-11 13:10:51 +00:00
|
|
|
data.SetPrinterName(name == NULL ? "" : name);
|
2003-05-22 15:25:25 +00:00
|
|
|
pr = new TPRINT_RCD;
|
2005-09-23 15:55:44 +00:00
|
|
|
data2RCD(data, pr);
|
2004-04-27 19:09:18 +00:00
|
|
|
*sizep = pr->GetSize();
|
2002-02-28 14:26:23 +00:00
|
|
|
#endif
|
2006-07-11 13:10:51 +00:00
|
|
|
|
|
|
|
if (ispdf)
|
|
|
|
xvt_print_set_name(pr, XVT_PDF_PRINTER_NAME);
|
2003-02-05 14:26:24 +00:00
|
|
|
|
2006-07-11 13:10:51 +00:00
|
|
|
return pr;
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
WINDOW xvt_print_create_win(PRINT_RCD* precp, const char* title)
|
2006-04-13 17:56:02 +00:00
|
|
|
|
2006-07-11 13:10:51 +00:00
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
|
2006-07-11 13:10:51 +00:00
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
if (m_PrintoutCache.Printing())
|
|
|
|
{
|
|
|
|
TwxPrintOut& po = m_PrintoutCache.Get(NULL);
|
2006-07-11 13:10:51 +00:00
|
|
|
po.InitDC(rcd, title);
|
2005-09-23 15:55:44 +00:00
|
|
|
po.OnBeginPrinting();
|
|
|
|
po.OnBeginDocument(1, 32000);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TwxPrintOut& po = m_PrintoutCache.Get(rcd);
|
2006-07-11 14:59:08 +00:00
|
|
|
po.InitDC(rcd, title);
|
2005-09-23 15:55:44 +00:00
|
|
|
}
|
|
|
|
return PRINTER_WIN;
|
2006-07-11 13:10:51 +00:00
|
|
|
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
2003-06-18 08:06:55 +00:00
|
|
|
void xvt_print_destroy(PRINT_RCD* precp)
|
2003-05-22 15:25:25 +00:00
|
|
|
{
|
2003-06-18 08:06:55 +00:00
|
|
|
delete precp;
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
RCT* xvt_print_get_next_band(void)
|
|
|
|
{
|
2002-02-28 14:26:23 +00:00
|
|
|
static bool yes = false;
|
|
|
|
static RCT rct;
|
|
|
|
yes = !yes;
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
if (!yes)
|
2002-02-28 14:26:23 +00:00
|
|
|
return NULL;
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
const TwxPrintOut& po = m_PrintoutCache.Get(NULL);
|
2002-02-28 14:26:23 +00:00
|
|
|
int w, h;
|
2005-09-23 15:55:44 +00:00
|
|
|
po.GetPageSizePixels(&w, &h);
|
2002-02-28 14:26:23 +00:00
|
|
|
rct.left = rct.top = 0;
|
|
|
|
rct.right = w;
|
|
|
|
rct.bottom = h;
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
return &rct;
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
2006-07-11 13:10:51 +00:00
|
|
|
BOOLEAN xvt_print_is_pdf(PRINT_RCD* precp)
|
|
|
|
{
|
|
|
|
char strName[MAX_PATH];
|
|
|
|
xvt_print_get_name(precp, strName, sizeof(strName));
|
|
|
|
return (xvt_str_compare_ignoring_case(strName, XVT_PDF_PRINTER_NAME) == 0);
|
|
|
|
}
|
|
|
|
|
2006-04-14 10:35:03 +00:00
|
|
|
BOOLEAN xvt_print_is_valid(const PRINT_RCD* precp)
|
2006-07-11 13:10:51 +00:00
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
{
|
2002-07-03 14:53:33 +00:00
|
|
|
BOOLEAN ok = precp != NULL && precp->pr == NULL;
|
2002-02-28 14:26:23 +00:00
|
|
|
if (ok)
|
|
|
|
{
|
2002-07-03 14:53:33 +00:00
|
|
|
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
|
2004-04-27 19:09:18 +00:00
|
|
|
|
|
|
|
#ifdef WIN32
|
2002-07-03 14:53:33 +00:00
|
|
|
ok = OsWin32_CheckPrinterInfo(rcd->m_data, rcd->m_size);
|
2003-05-22 15:25:25 +00:00
|
|
|
#else
|
2004-04-27 19:09:18 +00:00
|
|
|
wxPrintData data;
|
2005-09-23 15:55:44 +00:00
|
|
|
RCD2data(rcd, data);
|
2004-04-28 14:15:12 +00:00
|
|
|
ok = data.Ok();
|
2002-02-28 14:26:23 +00:00
|
|
|
#endif
|
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
return ok;
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
2006-04-14 10:35:03 +00:00
|
|
|
int xvt_print_get_name(const PRINT_RCD* precp, char* name, int sz_s)
|
2003-12-19 08:17:48 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
if (!xvt_print_is_valid(precp))
|
2005-03-03 15:42:04 +00:00
|
|
|
return 0;
|
|
|
|
|
2006-07-11 13:10:51 +00:00
|
|
|
|
2003-12-19 08:17:48 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
wxString n = ((const char*)precp) + 4;
|
2004-03-11 16:39:25 +00:00
|
|
|
if (n.Length() >= 30)
|
2003-12-19 08:17:48 +00:00
|
|
|
{
|
|
|
|
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 wxString pname = xvt_slist_get(plist, pitem, NULL);
|
|
|
|
if (pname.StartsWith(n))
|
|
|
|
{
|
|
|
|
n = pname;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xvt_slist_destroy(plist);
|
|
|
|
}
|
2004-04-27 19:09:18 +00:00
|
|
|
#else
|
|
|
|
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
|
|
|
|
wxPrintData data;
|
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
RCD2data(rcd, data);
|
2004-04-27 19:09:18 +00:00
|
|
|
wxString n = data.GetPrinterName();
|
|
|
|
#endif
|
2003-12-19 08:17:48 +00:00
|
|
|
if (name != NULL && sz_s > 0)
|
|
|
|
{
|
|
|
|
strncpy(name, n, sz_s);
|
|
|
|
name[sz_s-1] = '\0';
|
|
|
|
}
|
|
|
|
return n.Length();
|
|
|
|
}
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
BOOLEAN xvt_print_open(void)
|
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
return m_PrintoutCache.Ok();
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
2003-10-28 15:10:01 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CreateAbortWindow()
|
|
|
|
{
|
|
|
|
wxFrame* parent = (wxFrame*)TASK_WIN;
|
2006-12-13 16:22:33 +00:00
|
|
|
wxString strCaption = wxT("Stampa");
|
|
|
|
wxString strPrompt = strCaption + wxT(" in corso...");
|
|
|
|
wxPrintAbortDialog* win = new wxPrintAbortDialog(parent, strCaption,
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE);
|
2006-07-11 13:10:51 +00:00
|
|
|
|
2003-10-28 15:10:01 +00:00
|
|
|
wxBoxSizer *button_sizer = new wxBoxSizer( wxVERTICAL );
|
2006-12-13 16:22:33 +00:00
|
|
|
|
|
|
|
button_sizer->Add(new wxStaticText( win, wxID_STATIC, strPrompt, wxDefaultPosition, wxSize(320,-1)), 0, wxALL, 10 );
|
2003-10-28 15:10:01 +00:00
|
|
|
button_sizer->Add( new wxButton( win, wxID_CANCEL, wxT("Annulla") ), 0, wxALL | wxALIGN_CENTER, 10 );
|
|
|
|
|
2006-04-13 17:56:02 +00:00
|
|
|
win->SetAutoLayout(true);
|
|
|
|
win->SetSizer(button_sizer);
|
2003-10-28 15:10:01 +00:00
|
|
|
|
|
|
|
button_sizer->Fit(win);
|
2006-04-13 17:56:02 +00:00
|
|
|
button_sizer->SetSizeHints(win);
|
2003-10-28 15:10:01 +00:00
|
|
|
|
|
|
|
win->Show();
|
|
|
|
win->Update();
|
|
|
|
|
|
|
|
wxPrinterBase::sm_abortWindow = win;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DestroyAbortWindow()
|
|
|
|
{
|
|
|
|
if (wxPrinterBase::sm_abortWindow != NULL)
|
|
|
|
{
|
|
|
|
wxPrinterBase::sm_abortWindow->Hide();
|
|
|
|
delete wxPrinterBase::sm_abortWindow;
|
|
|
|
wxPrinterBase::sm_abortWindow = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
BOOLEAN xvt_print_start_thread(BOOLEAN(*print_fcn)(long), long data)
|
|
|
|
{
|
2006-04-13 17:56:02 +00:00
|
|
|
const wxString strDir = ::wxGetCwd(); // Memorizzo la directory corrente (Acrobat la cambia)
|
2004-06-29 11:20:17 +00:00
|
|
|
|
2003-10-28 15:10:01 +00:00
|
|
|
wxBeginBusyCursor();
|
2005-09-23 15:55:44 +00:00
|
|
|
|
|
|
|
m_PrintoutCache.Reset(); // Forza nuovo contesto di stampa
|
|
|
|
TwxPrintOut& po = m_PrintoutCache.Get(NULL);
|
|
|
|
m_PrintoutCache.Lock();
|
2003-10-28 15:10:01 +00:00
|
|
|
wxEndBusyCursor();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
2003-10-28 15:10:01 +00:00
|
|
|
CreateAbortWindow();
|
2005-09-23 15:55:44 +00:00
|
|
|
|
2004-03-25 16:35:20 +00:00
|
|
|
const BOOLEAN aborted = print_fcn(data);
|
2003-10-28 15:10:01 +00:00
|
|
|
DestroyAbortWindow();
|
2002-02-28 14:26:23 +00:00
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
po.OnEndDocument();
|
|
|
|
po.OnEndPrinting();
|
2003-10-30 18:13:09 +00:00
|
|
|
|
2005-09-23 15:55:44 +00:00
|
|
|
m_PrintoutCache.Unlock();
|
|
|
|
m_PrintoutCache.Reset();
|
2003-10-28 15:10:01 +00:00
|
|
|
|
2006-04-13 17:56:02 +00:00
|
|
|
::wxSetWorkingDirectory(strDir); // Ripristino la directory corrente (Acrobat l'ha cambiata)
|
2004-06-29 11:20:17 +00:00
|
|
|
|
2004-03-25 16:35:20 +00:00
|
|
|
return aborted;
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
2006-04-13 17:56:02 +00:00
|
|
|
BOOLEAN xvt_print_suspend_thread()
|
|
|
|
{
|
2006-04-14 10:35:03 +00:00
|
|
|
BOOLEAN ok = m_PrintoutCache.Printing();
|
2006-04-13 17:56:02 +00:00
|
|
|
if (ok)
|
|
|
|
{
|
2006-04-14 10:35:03 +00:00
|
|
|
TwxPrintOut& po = m_PrintoutCache.Get(NULL); // Sembra generare una pagina vuota indesiderata
|
2006-07-11 13:10:51 +00:00
|
|
|
po.OnEndDocument(); // Sembra generare una pagina vuota indesiderata
|
2006-04-14 10:35:03 +00:00
|
|
|
po.OnEndPrinting();
|
2006-04-13 17:56:02 +00:00
|
|
|
}
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN xvt_print_restart_thread()
|
|
|
|
{
|
2006-04-14 10:35:03 +00:00
|
|
|
TwxPrintOut& po = m_PrintoutCache.Get(NULL);
|
|
|
|
po.OnBeginPrinting();
|
|
|
|
po.OnBeginDocument(1, 32000);
|
|
|
|
|
|
|
|
return TRUE;
|
2006-04-13 17:56:02 +00:00
|
|
|
}
|
|
|
|
|
2006-07-11 13:10:51 +00:00
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
BOOLEAN xvt_print_open_page(PRINT_RCD* precp)
|
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
BOOLEAN ok = m_PrintoutCache.Printing();
|
2002-02-28 14:26:23 +00:00
|
|
|
if (ok)
|
2003-02-05 14:26:24 +00:00
|
|
|
{
|
2003-10-28 15:10:01 +00:00
|
|
|
if (wxPrinterBase::sm_abortIt)
|
|
|
|
ok = FALSE;
|
|
|
|
else
|
2004-06-28 15:24:28 +00:00
|
|
|
{
|
2005-09-23 15:55:44 +00:00
|
|
|
TwxPrintOut& po = m_PrintoutCache.Get(NULL);
|
|
|
|
po.GetDC()->StartPage();
|
2004-06-28 15:24:28 +00:00
|
|
|
TPrintDC::SetPageStart(); // Flag per azzeramento dati DC
|
|
|
|
}
|
2003-02-05 14:26:24 +00:00
|
|
|
}
|
2003-05-22 15:25:25 +00:00
|
|
|
return ok;
|
2002-02-28 14:26:23 +00:00
|
|
|
}
|
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Added by XVAGA
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
#ifdef LINUX
|
2004-04-27 19:09:18 +00:00
|
|
|
static const char * cups_file = "/etc/cups/printers.conf";
|
|
|
|
static const char * cups_local_file = "./printers.conf";
|
|
|
|
static const char * prcap_local_file = "./printcap";
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
static bool is_cups()
|
|
|
|
{
|
|
|
|
static int printer_system = -1;
|
|
|
|
|
|
|
|
if (printer_system < 0)
|
2004-04-27 19:09:18 +00:00
|
|
|
printer_system = xvt_fsys_file_exists(cups_file) ? 1 : 2;
|
|
|
|
|
|
|
|
return printer_system == 1;
|
2003-05-22 15:25:25 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
SLIST xvt_print_list_devices()
|
|
|
|
{
|
|
|
|
SLIST list = xvt_slist_create();
|
|
|
|
#ifdef WIN32
|
2006-04-13 17:56:02 +00:00
|
|
|
/* Vecchio modo oblsoleto
|
2003-04-17 12:53:36 +00:00
|
|
|
char buf[4096]; memset(buf, 0, sizeof(buf));
|
2003-04-16 15:50:37 +00:00
|
|
|
GetProfileString("devices", NULL, "", buf, sizeof(buf));
|
|
|
|
int start = 0;
|
2003-04-17 12:53:36 +00:00
|
|
|
for (int i = 0; i < sizeof(buf); i++) if (buf[i] == '\0')
|
2003-04-16 15:50:37 +00:00
|
|
|
{
|
2003-04-17 12:53:36 +00:00
|
|
|
const char* pname = buf+start;
|
2003-05-22 15:25:25 +00:00
|
|
|
if (*pname == '\0')
|
2003-04-17 12:53:36 +00:00
|
|
|
break;
|
|
|
|
xvt_slist_add_at_elt(list, NULL, pname, NULL);
|
|
|
|
start = i+1;
|
2006-04-13 17:56:02 +00:00
|
|
|
} */
|
|
|
|
|
|
|
|
const DWORD dwFlags = PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS;
|
|
|
|
const int level = xvt_sys_get_os_version() >= XVT_WS_WIN_NT ? 4 : 5;
|
|
|
|
DWORD dwSize = 0, dwPrinters = 0;
|
|
|
|
::EnumPrinters (dwFlags, NULL, level, NULL, 0, &dwSize, &dwPrinters);
|
|
|
|
if (dwSize > 0)
|
|
|
|
{
|
|
|
|
BYTE* pBuffer = new BYTE[dwSize];
|
|
|
|
::EnumPrinters (dwFlags, NULL, level, pBuffer, dwSize, &dwSize, &dwPrinters);
|
|
|
|
if (level == 4)
|
|
|
|
{
|
|
|
|
const PRINTER_INFO_4* pPrnInfo = (const PRINTER_INFO_4*)pBuffer;
|
|
|
|
for (UINT i=0; i < dwPrinters; i++)
|
|
|
|
{
|
|
|
|
xvt_slist_add_at_elt(list, NULL, pPrnInfo->pPrinterName, NULL);
|
|
|
|
pPrnInfo++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const PRINTER_INFO_5* pPrnInfo = (const PRINTER_INFO_5*)pBuffer;
|
|
|
|
for (UINT i=0; i < dwPrinters; i++)
|
|
|
|
{
|
|
|
|
xvt_slist_add_at_elt(list, NULL, pPrnInfo->pPrinterName, NULL);
|
|
|
|
pPrnInfo++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete[] pBuffer;
|
2003-04-16 15:50:37 +00:00
|
|
|
}
|
|
|
|
#else
|
2003-05-22 15:25:25 +00:00
|
|
|
if (is_cups())
|
|
|
|
{
|
2004-04-27 19:09:18 +00:00
|
|
|
ifstream p(cups_local_file);
|
2003-05-22 15:25:25 +00:00
|
|
|
char line[4096];
|
2004-04-27 19:09:18 +00:00
|
|
|
const char * str_to_find = "Printer";
|
|
|
|
|
2003-05-22 15:25:25 +00:00
|
|
|
while (p.getline(line, sizeof(line)))
|
|
|
|
{
|
2004-04-27 19:09:18 +00:00
|
|
|
char * s;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
2004-04-27 19:09:18 +00:00
|
|
|
if (line[0] == '<' && line[1] != '/' &&
|
|
|
|
(s = strstr(line, str_to_find)) != NULL)
|
|
|
|
{
|
|
|
|
s += strlen(str_to_find);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
2004-04-27 19:09:18 +00:00
|
|
|
while (isspace(*s))
|
|
|
|
s++;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
2004-04-27 19:09:18 +00:00
|
|
|
if (*s)
|
|
|
|
{
|
|
|
|
char * l = s + strlen(s) - 1;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
2004-04-27 19:09:18 +00:00
|
|
|
while (*l == '>' || isspace(*l))
|
2003-05-22 15:25:25 +00:00
|
|
|
l--;
|
2004-04-27 19:09:18 +00:00
|
|
|
*(l + 1) = '\0';
|
|
|
|
xvt_slist_add_at_elt(list, NULL, s, 0L);
|
2003-05-22 15:25:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-04-27 19:09:18 +00:00
|
|
|
ifstream p(prcap_local_file); // vedere
|
2003-05-22 15:25:25 +00:00
|
|
|
char line[4096];
|
|
|
|
|
|
|
|
while (p.getline(line, sizeof(line)))
|
|
|
|
{
|
|
|
|
if (line[0] != '#')
|
|
|
|
{
|
|
|
|
const int len = strlen(line);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
const char c = line[i];
|
|
|
|
|
|
|
|
if (!(isalpha(c) || isdigit(c) || isblank(c)))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
line[i] = '\0';
|
|
|
|
xvt_slist_add_at_elt(list, NULL, line, 0L);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-04-16 15:50:37 +00:00
|
|
|
#endif
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN xvt_print_set_default_device(const char* name)
|
2003-05-22 15:25:25 +00:00
|
|
|
{
|
2003-04-16 15:50:37 +00:00
|
|
|
BOOLEAN ok = name && *name > ' ';
|
|
|
|
#ifdef WIN32
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
wxString pdev(name);
|
|
|
|
if (pdev.Find(',') < 0)
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
char szDevice[256];
|
2003-04-17 12:53:36 +00:00
|
|
|
::GetProfileString ("devices", pdev, "", szDevice, sizeof(szDevice));
|
2003-04-16 15:50:37 +00:00
|
|
|
pdev << ',' << szDevice;
|
2003-05-22 15:25:25 +00:00
|
|
|
}
|
|
|
|
ok = ::WriteProfileString("windows", "device", pdev) != 0;
|
2003-04-16 15:50:37 +00:00
|
|
|
}
|
|
|
|
#endif
|
2003-05-22 15:25:25 +00:00
|
|
|
return ok;
|
2003-04-16 15:50:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN xvt_print_get_default_device(char* name, int namesize)
|
|
|
|
{
|
2003-05-22 15:25:25 +00:00
|
|
|
bool ok = FALSE;
|
2003-04-17 12:53:36 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
ok = ::GetProfileString ("windows", "device", ",,,", name, namesize) != 0;
|
|
|
|
#else
|
2003-05-22 15:25:25 +00:00
|
|
|
*name = '\0';
|
|
|
|
if (is_cups())
|
|
|
|
{
|
2004-04-27 19:09:18 +00:00
|
|
|
ifstream p(cups_local_file);
|
2003-05-22 15:25:25 +00:00
|
|
|
char line[4096];
|
2004-04-27 19:09:18 +00:00
|
|
|
const char * str_to_find = "<DefaultPrinter";
|
2003-05-22 15:25:25 +00:00
|
|
|
|
|
|
|
while (p.getline(line, sizeof(line)))
|
|
|
|
{
|
2004-04-27 19:09:18 +00:00
|
|
|
char * s = strstr(line, str_to_find) ;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
2004-04-27 19:09:18 +00:00
|
|
|
if (s != NULL)
|
|
|
|
{
|
|
|
|
s += strlen(str_to_find);
|
2003-05-22 15:25:25 +00:00
|
|
|
|
2004-04-27 19:09:18 +00:00
|
|
|
while (isspace(*s))
|
|
|
|
s++;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
2004-04-27 19:09:18 +00:00
|
|
|
if (*s)
|
|
|
|
{
|
|
|
|
char * l = s + strlen(s) - 1;
|
2003-05-22 15:25:25 +00:00
|
|
|
|
2004-04-27 19:09:18 +00:00
|
|
|
while (*l == '>' || isspace(*l))
|
|
|
|
l--;
|
|
|
|
*(l + 1) = '\0';
|
|
|
|
strcpy(name, s);
|
2003-05-22 15:25:25 +00:00
|
|
|
}
|
2004-04-27 19:09:18 +00:00
|
|
|
ok = TRUE;
|
2003-05-22 15:25:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-04-17 12:53:36 +00:00
|
|
|
#endif
|
2003-05-22 15:25:25 +00:00
|
|
|
|
2003-04-16 15:50:37 +00:00
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2004-02-06 15:16:17 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Gestione files di configurazione
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
int xvt_fsys_get_campo_stp_value(const char* name, char* value, int valsize)
|
|
|
|
{
|
|
|
|
BOOLEAN bFound = FALSE;
|
|
|
|
#ifdef WIN32
|
2006-04-13 17:56:02 +00:00
|
|
|
const char* const stpfile = "c:/campo.stp";
|
2004-02-06 15:16:17 +00:00
|
|
|
int p;
|
|
|
|
DIRECTORY dir;
|
|
|
|
char exedir[_MAX_PATH], path[_MAX_PATH];
|
|
|
|
xvt_fsys_get_default_dir(&dir);
|
|
|
|
xvt_fsys_convert_dir_to_str(&dir, exedir, sizeof(exedir));
|
|
|
|
|
|
|
|
for (p = 1; ; p++)
|
|
|
|
{
|
|
|
|
char para[4]; sprintf(para, "%d", p);
|
2006-04-13 17:56:02 +00:00
|
|
|
int len = xvt_sys_get_profile_string(stpfile, para, "Program", "", path, sizeof(path));
|
2004-02-06 15:16:17 +00:00
|
|
|
if (len <= 0)
|
|
|
|
break;
|
|
|
|
if (path[len-1] == '\\' || path[len-1] == '/')
|
|
|
|
{
|
|
|
|
len--;
|
|
|
|
path[len] = '\0';
|
|
|
|
}
|
|
|
|
if (xvt_str_compare_ignoring_case(path, exedir) == 0)
|
|
|
|
{
|
|
|
|
xvt_sys_get_profile_string(stpfile, para, name, "", value, valsize);
|
|
|
|
bFound = *value > ' ';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return bFound;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
@($) CGetCampoIni FILES
|
|
|
|
|
|
|
|
@(ID)
|
|
|
|
Restituisce il nome del file che contiene il prefisso corrente.
|
|
|
|
@(FD)
|
|
|
|
|
|
|
|
@(ISV)
|
|
|
|
s,s1 = stringhe di lavoro.
|
|
|
|
|
|
|
|
Versione WIN32 e LINUX.
|
|
|
|
@(FSV)
|
2004-03-18 12:16:40 +00:00
|
|
|
*/
|
2004-02-06 15:16:17 +00:00
|
|
|
const char* xvt_fsys_get_campo_ini()
|
|
|
|
{
|
|
|
|
static char* prawin = NULL;
|
|
|
|
if (prawin == NULL)
|
|
|
|
{
|
|
|
|
BOOLEAN bFound = FALSE;
|
2004-03-12 14:21:37 +00:00
|
|
|
char exedir[_MAX_PATH], path[_MAX_PATH];
|
2004-02-06 15:16:17 +00:00
|
|
|
// Nelle installazioni sfigate con programmi in rete cerca di stabilire il percorso locale di Campo.ini
|
2004-03-18 12:16:40 +00:00
|
|
|
DIRECTORY dir;
|
2004-03-12 14:21:37 +00:00
|
|
|
|
2004-02-06 15:16:17 +00:00
|
|
|
xvt_fsys_get_default_dir(&dir);
|
|
|
|
xvt_fsys_convert_dir_to_str(&dir, exedir, sizeof(exedir));
|
2004-03-18 12:16:40 +00:00
|
|
|
#ifdef WIN32
|
2004-02-06 15:16:17 +00:00
|
|
|
if (xvt_fsys_is_network_drive(exedir))
|
|
|
|
bFound = xvt_fsys_get_campo_stp_value("CampoIni", path, sizeof(path));
|
2004-04-05 13:03:51 +00:00
|
|
|
|
|
|
|
if (!bFound)
|
|
|
|
{
|
2005-03-03 15:42:04 +00:00
|
|
|
if (OsWin32_IsWindowsServer())
|
2004-04-05 13:03:51 +00:00
|
|
|
{
|
|
|
|
xvt_fsys_build_pathname(path, NULL, wxGetHomeDir(), "campo", "ini", NULL);
|
|
|
|
bFound = xvt_fsys_file_exists(path);
|
|
|
|
if (!bFound)
|
2004-02-06 15:16:17 +00:00
|
|
|
{
|
2004-04-05 13:03:51 +00:00
|
|
|
char pathstd[_MAX_PATH];
|
|
|
|
xvt_fsys_build_pathname(pathstd, NULL, exedir, "campo", "ini", NULL);
|
|
|
|
if (xvt_fsys_file_exists(pathstd))
|
|
|
|
wxCopyFile(pathstd, path);
|
2004-02-06 15:16:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-04-05 13:03:51 +00:00
|
|
|
|
2004-04-01 09:16:46 +00:00
|
|
|
if (!bFound)
|
|
|
|
xvt_fsys_build_pathname(path, NULL, exedir, "campo", "ini", NULL);
|
|
|
|
#else
|
2004-03-31 12:57:12 +00:00
|
|
|
if (!bFound)
|
|
|
|
{
|
2004-04-01 09:16:46 +00:00
|
|
|
char username[32];
|
2004-03-31 12:57:12 +00:00
|
|
|
char ininame[_MAX_FNAME];
|
|
|
|
|
2004-04-01 09:16:46 +00:00
|
|
|
xvt_sys_get_user_name(username, sizeof(username));
|
|
|
|
if (xvt_str_compare_ignoring_case(username, "root") == 0)
|
2004-03-31 12:57:12 +00:00
|
|
|
*username = '\0';
|
|
|
|
|
|
|
|
sprintf(ininame, "campo%s", username);
|
|
|
|
xvt_fsys_build_pathname(path, NULL, exedir, ininame, "ini", NULL);
|
|
|
|
if (!xvt_fsys_file_exists(path) && *username > ' ')
|
|
|
|
{
|
|
|
|
char pathstd[_MAX_PATH];
|
|
|
|
xvt_fsys_build_pathname(pathstd, NULL, exedir, "campo", "ini", NULL);
|
|
|
|
if (xvt_fsys_file_exists(pathstd))
|
|
|
|
wxCopyFile(pathstd, path);
|
|
|
|
}
|
2004-04-01 09:16:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
2004-03-31 12:57:12 +00:00
|
|
|
if (!xvt_fsys_file_exists(path))
|
|
|
|
{
|
|
|
|
char msg[256];
|
|
|
|
sprintf(msg, "Impossibile aprire '%s'", (const char *)path);
|
2005-09-23 15:55:44 +00:00
|
|
|
xvt_dm_post_fatal_exit(msg);
|
2004-03-31 12:57:12 +00:00
|
|
|
}
|
2004-02-06 15:16:17 +00:00
|
|
|
prawin = xvt_str_duplicate(path);
|
|
|
|
}
|
|
|
|
return prawin;
|
2006-12-13 16:22:33 +00:00
|
|
|
}
|