Patch level : 2.0 476
Files correlati : xvagaa.dll Ricompilazione Demo : [ ] Commento : Modifiche per Linux git-svn-id: svn://10.65.10.50/trunk@11172 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
6055e4ab1a
commit
9d7cb84959
@ -1,7 +1,10 @@
|
||||
#include "wxinc.h"
|
||||
|
||||
#include <fstream.h>
|
||||
|
||||
#ifdef LINUX
|
||||
#include "xvt_type.h"
|
||||
#endif
|
||||
|
||||
#include "agasys.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -304,7 +307,7 @@ bool aga_zip_filelist(const char* filelist, const char* zipfile)
|
||||
ifstream fin(filelist);
|
||||
while (!fin.eof())
|
||||
{
|
||||
char name[MAX_PATH];
|
||||
char name[_MAX_PATH];
|
||||
fin.getline(name, sizeof(name));
|
||||
if (*name)
|
||||
aFiles.Add(name);
|
||||
|
@ -8,7 +8,7 @@
|
||||
#define XVTDLL __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define
|
||||
#define XVTDLL
|
||||
#endif
|
||||
|
||||
XVTDLL bool aga_unzip(const char* zipfile, const char* destdir);
|
||||
|
261
xvaga/oslinux.cpp
Executable file
261
xvaga/oslinux.cpp
Executable file
@ -0,0 +1,261 @@
|
||||
#include "wxinc.h"
|
||||
#include "wx/print.h"
|
||||
#include "wx/printdlg.h"
|
||||
|
||||
#include "xvt.h"
|
||||
#include "oslinux.h"
|
||||
|
||||
#include "xvt_menu.h"
|
||||
#include "xvt_help.h"
|
||||
#include "xvintern.h"
|
||||
#include <wx/fontenum.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/snglinst.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <mntent.h>
|
||||
#include <sys/vfs.h>
|
||||
|
||||
wxString OsLinux_File2App(const char* filename)
|
||||
{
|
||||
wxString app;
|
||||
|
||||
SORRY_BOX();
|
||||
return app;
|
||||
}
|
||||
|
||||
int OsLinux_EnumerateFamilies(char** families, int max_count)
|
||||
{
|
||||
wxFontEnumerator ef;
|
||||
|
||||
ef.EnumerateFacenames();
|
||||
wxArrayString * fonts = ef.GetFacenames();
|
||||
|
||||
size_t items = fonts->GetCount();
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < items; i++)
|
||||
strcpy(families[i], (*fonts)[i].c_str());
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
int OsLinux_EnumerateSizes(const char* name, long* sizes, short* scalable, int max_count)
|
||||
{
|
||||
int i = 0;
|
||||
TFontId f;
|
||||
wxPrinter printer;
|
||||
wxPostScriptDC dc(printer.GetPrintDialogData().GetPrintData());
|
||||
|
||||
f.SetFaceName(name);
|
||||
for (int size = 7; size < 80; size++)
|
||||
{
|
||||
f.SetPointSize(size);
|
||||
if (f.Font((wxDC *) &dc).Ok())
|
||||
sizes[i++] = size;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void OsLinux_PlaceProcessInWindow(unsigned int instance, const char* name, unsigned int parent)
|
||||
{
|
||||
SORRY_BOX();
|
||||
}
|
||||
|
||||
void OsLinux_UpdateWindow(unsigned int handle)
|
||||
{
|
||||
SORRY_BOX();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Hardlock Support
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
#include "hlapi_c.h"
|
||||
|
||||
bool OsLinux_HL_Login(unsigned short address, const unsigned char* label, const unsigned char* password)
|
||||
{
|
||||
int err = HL_LOGIN(address, LOCAL_DEVICE, (unsigned char*)label, (unsigned char*)password);
|
||||
return err == STATUS_OK;
|
||||
}
|
||||
|
||||
bool OsLinux_HL_Logout()
|
||||
{
|
||||
HL_LOGOUT();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool OsLinux_HL_Read(unsigned short reg, unsigned short* data)
|
||||
{
|
||||
int err = HL_READ(reg, data);
|
||||
return err == STATUS_OK;
|
||||
}
|
||||
|
||||
bool OsLinux_HL_ReadBlock(unsigned char* data)
|
||||
{
|
||||
int err = HL_READBL(data);
|
||||
return err == STATUS_OK;
|
||||
}
|
||||
|
||||
bool OsLinux_HL_Write(unsigned short reg, unsigned short data)
|
||||
{
|
||||
int err = HL_WRITE(reg, data);
|
||||
return err == STATUS_OK;
|
||||
}
|
||||
|
||||
bool OsLinux_HL_Crypt(unsigned short* data) // Array di 4 words (8 bytes)
|
||||
{
|
||||
int err = HL_CODE(data, 1);
|
||||
return err == STATUS_OK;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Eutron Smartlink Support
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
#include "skeylink.h"
|
||||
|
||||
static KEY_NET _eutron_key;
|
||||
|
||||
static short smartlink(KEY_NET * key)
|
||||
{
|
||||
SKEY_DATA skey;
|
||||
int i;
|
||||
|
||||
skey.lpt = key->lpt;
|
||||
skey.command = key->command;
|
||||
for (i = 0; i < LABEL_LENGTH; i++)
|
||||
skey.label[i] = key->label[i];
|
||||
for (i = 0; i < PASSWORD_LENGTH; i++)
|
||||
skey.password[i] = key->password[i];
|
||||
for (i = 0; i < DATA_LENGTH; i++)
|
||||
skey.data[i] = key->data[i];
|
||||
skey.fail_counter = key->fail_counter;
|
||||
skey.status = key->status;
|
||||
for (i = 0; i < EXTENDED_DATA_LENGTH; i++)
|
||||
skey.ext_data[i] = key->ext_data[i];
|
||||
|
||||
short retval = clink(&skey);
|
||||
|
||||
key->lpt = skey.lpt;
|
||||
key->command = skey.command;
|
||||
for (i = 0; i < LABEL_LENGTH; i++)
|
||||
key->label[i] = skey.label[i];
|
||||
for (i = 0; i < PASSWORD_LENGTH; i++)
|
||||
key->password[i] = skey.password[i];
|
||||
for (i = 0; i < DATA_LENGTH; i++)
|
||||
key->data[i] = skey.data[i];
|
||||
key->fail_counter = skey.fail_counter;
|
||||
key->status = skey.status;
|
||||
for (i = 0; i < EXTENDED_DATA_LENGTH; i++)
|
||||
key->ext_data[i] = skey.ext_data[i];
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool OsLinux_SL_Crypt(unsigned short* data)
|
||||
{
|
||||
_eutron_key.net_command = NET_KEY_ACCESS;
|
||||
_eutron_key.command = SCRAMBLING_MODE;
|
||||
memcpy(_eutron_key.data, data, 8);
|
||||
smartlink(&_eutron_key);
|
||||
if (_eutron_key.status == ST_OK)
|
||||
memcpy(data, _eutron_key.data, 8);
|
||||
return _eutron_key.status == ST_OK;
|
||||
}
|
||||
|
||||
bool OsLinux_SL_Login(const unsigned char* label, const unsigned char* password)
|
||||
{
|
||||
memset(&_eutron_key, 0, sizeof(KEY_NET));
|
||||
_eutron_key.net_command = NET_KEY_OPEN;
|
||||
_eutron_key.status = ST_HW_FAILURE; // Don't leave ST_OK = 0 here!
|
||||
memcpy(_eutron_key.label, label, strlen((const char*)label));
|
||||
memcpy(_eutron_key.password, password, strlen((const char*)password));
|
||||
|
||||
smartlink(&_eutron_key);
|
||||
return _eutron_key.status == ST_OK;
|
||||
}
|
||||
|
||||
bool OsLinux_SL_Logout()
|
||||
{
|
||||
_eutron_key.net_command = NET_KEY_CLOSE;
|
||||
_eutron_key.command = 0;
|
||||
smartlink(&_eutron_key);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OsLinux_SL_ReadBlock(unsigned short reg, unsigned short size, unsigned short* data)
|
||||
{
|
||||
_eutron_key.net_command = NET_KEY_ACCESS;
|
||||
_eutron_key.command = BLOCK_READING_MODE;
|
||||
unsigned short* pointer = (unsigned short*)(&_eutron_key.data[0]);
|
||||
unsigned short* number = (unsigned short*)(&_eutron_key.data[2]);
|
||||
*pointer = reg;
|
||||
*number = size;
|
||||
smartlink(&_eutron_key);
|
||||
bool ok = _eutron_key.status == ST_OK;
|
||||
if (ok)
|
||||
memcpy(data, &_eutron_key.data[4], size*sizeof(unsigned short));
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool OsLinux_SL_WriteBlock(unsigned short reg, unsigned short size, const unsigned short* data)
|
||||
{
|
||||
_eutron_key.net_command = NET_KEY_ACCESS;
|
||||
_eutron_key.command = BLOCK_WRITING_MODE;
|
||||
unsigned short* pointer = (unsigned short*)(&_eutron_key.data[0]);
|
||||
unsigned short* number = (unsigned short*)(&_eutron_key.data[2]);
|
||||
*pointer = reg;
|
||||
*number = size;
|
||||
memcpy(&_eutron_key.data[4], data, size*sizeof(unsigned short));
|
||||
smartlink(&_eutron_key);
|
||||
return _eutron_key.status == ST_OK;
|
||||
}
|
||||
|
||||
void OsLinux_GetFileSys(const char* path, char * dev, char * dir, char * type)
|
||||
{
|
||||
struct mntent *m;
|
||||
FILE *f = setmntent("/etc/mnttab", "r");
|
||||
|
||||
while ((m = getmntent(f)) && strncmp(path, m->mnt_dir, strlen(m->mnt_dir)) != 0);
|
||||
if (m)
|
||||
{
|
||||
if (dev) strcpy(dev, m->mnt_fsname);
|
||||
if (dir) strcpy(dir, m->mnt_dir);
|
||||
if (type) strcpy(type, m->mnt_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dev) *dev = '\0';
|
||||
if (dir) *dir = '\0';
|
||||
if (type) *type = '\0';
|
||||
}
|
||||
endmntent(f);
|
||||
}
|
||||
|
||||
|
||||
bool OsLinux_IsNetworkDrive(const char * path)
|
||||
{
|
||||
struct statfs buf;
|
||||
|
||||
if (statfs(path, &buf) == -1)
|
||||
return FALSE;
|
||||
return (buf.f_type == 0x6969 /*NFS_SUPER_MAGIC */) ||
|
||||
(buf.f_type == 0x517B /*SMB_SUPER_MAGIC)*/);
|
||||
}
|
||||
|
||||
int64_t OsLinux_GetDiskFreeSpace(const char * path)
|
||||
{
|
||||
struct statfs buf;
|
||||
int64_t nBytes = 0L;
|
||||
|
||||
if (statfs(path, &buf) != -1)
|
||||
{
|
||||
nBytes = buf.f_bsize;
|
||||
nBytes *= buf.f_bavail;
|
||||
nBytes *= 1024;
|
||||
}
|
||||
|
||||
return nBytes;
|
||||
}
|
22
xvaga/oslinux.h
Executable file
22
xvaga/oslinux.h
Executable file
@ -0,0 +1,22 @@
|
||||
wxString OsLinux_File2App(const char* filename);
|
||||
|
||||
int OsLinux_EnumerateFamilies(char** families, int max_count);
|
||||
int OsLinux_EnumerateSizes(const char* name, long* sizes, short* scalable, int max_count);
|
||||
|
||||
void OsLinux_PlaceProcessInWindow(unsigned int instance, const char* name, unsigned int parent);
|
||||
void OsLinux_UpdateWindow(unsigned int handle);
|
||||
|
||||
bool OsLinux_HL_Crypt(unsigned short* data);
|
||||
bool OsLinux_HL_Login(unsigned short address, const unsigned char* label, const unsigned char* password);
|
||||
bool OsLinux_HL_Logout() ;
|
||||
bool OsLinux_HL_Read(unsigned short reg, unsigned short* data);
|
||||
bool OsLinux_HL_ReadBlock(unsigned char* data);
|
||||
bool OsLinux_HL_Write(unsigned short reg, unsigned short data);
|
||||
bool OsLinux_SL_Crypt(unsigned short* data);
|
||||
bool OsLinux_SL_Login(const unsigned char* label, const unsigned char* password);
|
||||
bool OsLinux_SL_Logout() ;
|
||||
bool OsLinux_SL_ReadBlock(unsigned short reg, unsigned short size, unsigned short* data);
|
||||
bool OsLinux_SL_WriteBlock(unsigned short reg, unsigned short size, const unsigned short* data);
|
||||
void OsLinux_GetFileSys(const char* path, char * dev, char * dir, char * type);
|
||||
bool OsLinux_IsNetworkDrive(const char * path);
|
||||
int64_t OsLinux_GetDiskFreeSpace(const char * path);
|
@ -172,7 +172,12 @@ typedef struct __KEY_NET {
|
||||
Call the driver.
|
||||
Return key->k.status code
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
short __cdecl smartlink(KEY_NET*);
|
||||
#else
|
||||
int clink(SKEY_DATA *);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#ifndef __WXINC_H__
|
||||
#define __WXINC_H__
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#define __WINDOWS__
|
||||
#define __WXMSW__
|
||||
@ -10,9 +11,14 @@
|
||||
#define WINVER 0x0400
|
||||
#define STRICT
|
||||
#define WXUSINGDLL 1
|
||||
#include <wx/wxprec.h>
|
||||
#else
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#define _LARGE_FILES
|
||||
#define __WXGTK__
|
||||
#define GTK_NO_CHECK_CASTS
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
193
xvaga/xvaga.cpp
193
xvaga/xvaga.cpp
@ -19,6 +19,9 @@
|
||||
|
||||
#ifdef WIN32
|
||||
#include "oswin32.h"
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include "oslinux.h"
|
||||
#endif
|
||||
|
||||
// Funzione interna di utilita'
|
||||
@ -52,15 +55,13 @@ void assert_box(bool test, int line)
|
||||
}
|
||||
}
|
||||
|
||||
#define SORRY_BOX() sorry_box(__LINE__)
|
||||
|
||||
void sorry_box(int line)
|
||||
void xvt_sys_sorry_box(const char * file,int line)
|
||||
{
|
||||
static wxHashTable sorry;
|
||||
if (sorry.Get(line) == NULL)
|
||||
{
|
||||
sorry.Put(line, &sorry); // Dummy
|
||||
const wxString strMessage = wxString::Format("Function at line %d not implemented", line);
|
||||
const wxString strMessage = wxString::Format("Function in file %s at line %d not implemented", file, line);
|
||||
::wxMessageBox(strMessage);
|
||||
}
|
||||
}
|
||||
@ -144,7 +145,11 @@ wxCursor* GetCursorResource(int rid)
|
||||
wxString strName = ::GetResourceName("Cursor", rid);
|
||||
if (::wxFileExists(strName))
|
||||
{
|
||||
#ifdef WIN32
|
||||
cursor = new wxCursor(strName, wxBITMAP_TYPE_CUR);
|
||||
#else
|
||||
cursor = wxSTANDARD_CURSOR;
|
||||
#endif
|
||||
if (!cursor->Ok())
|
||||
{
|
||||
delete cursor;
|
||||
@ -189,7 +194,7 @@ public:
|
||||
WINDOW Owner() const { return _owner; }
|
||||
void Kill();
|
||||
|
||||
TwxCaret() : _visible(false), _owner(NULL_WIN) { }
|
||||
TwxCaret() : _owner(NULL_WIN), _visible(false) { }
|
||||
virtual ~TwxCaret() { Kill(); }
|
||||
} _TheCaret;
|
||||
|
||||
@ -299,7 +304,8 @@ static int PatternToStyle(PAT_STYLE pat)
|
||||
case PAT_CROSS: style = wxCROSS_HATCH; break;
|
||||
case PAT_DIAGCROSS: style = wxCROSSDIAG_HATCH; break;
|
||||
case PAT_RUBBER:
|
||||
case PAT_SPECIAL: style = wxSOLID; SORRY_BOX(); break;
|
||||
case PAT_SPECIAL:
|
||||
default: style = wxSOLID; SORRY_BOX(); break;
|
||||
}
|
||||
return style;
|
||||
}
|
||||
@ -586,7 +592,7 @@ public:
|
||||
void SetMenuTree(const MENU_ITEM* menu);
|
||||
MENU_ITEM* GetMenuTree() const { return m_menu; }
|
||||
|
||||
TwxWindow() : _timer(NULL), _eh(NULL) { }
|
||||
TwxWindow() : m_menu(NULL), _type(W_DOC), _eh(NULL), _app_data(0L), _timer(NULL) { }
|
||||
TwxWindow(wxWindow *parent, wxWindowID id, const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0);
|
||||
@ -1053,7 +1059,8 @@ void TTaskWin::SetMenuTree(const MENU_ITEM* tree)
|
||||
pMenu->DoAppend(item);
|
||||
}
|
||||
const int nLast = bar->GetMenuCount()-1;
|
||||
for (int m = 2; m < nLast; m++)
|
||||
int m;
|
||||
for (m = 2; m < nLast; m++)
|
||||
{
|
||||
wxMenu* pMenu = bar->GetMenu(m);
|
||||
if (pMenu->FindItem(tree->child->tag))
|
||||
@ -1184,8 +1191,16 @@ void xvt_app_create(int argc, char **argv, unsigned long flags,
|
||||
Menus[2]->Append(M_HELP_HELPONHELP, "&Uso della guida");
|
||||
Menus[2]->AppendSeparator();
|
||||
Menus[2]->Append(M_FILE_ABOUT+1, "&Informazioni");
|
||||
|
||||
#ifdef WIN32
|
||||
wxMenuBar* pMenubar = new wxMenuBar(3, Menus, Title);
|
||||
#else
|
||||
wxMenuBar* pMenubar = new wxMenuBar();
|
||||
|
||||
for (int i= 0; i < 3; i++)
|
||||
pMenubar->Append(Menus[i], Title[i]);
|
||||
((wxFrame*)_task_win)->SetMenuBar(pMenubar);
|
||||
#endif
|
||||
|
||||
_task_win->Show();
|
||||
if (style & wxMAXIMIZE)
|
||||
@ -1353,6 +1368,8 @@ BOOLEAN xvt_dongle_hl_crypt(unsigned short* data) // Array di 4 words (8 bytes)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return OsWin32_HL_Crypt(data);
|
||||
#else
|
||||
return OsLinux_HL_Crypt(data);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
@ -1361,6 +1378,8 @@ BOOLEAN xvt_dongle_hl_login(unsigned short address, const unsigned char* label,
|
||||
{
|
||||
#ifdef WIN32
|
||||
return OsWin32_HL_Login(address, label, password);
|
||||
#else
|
||||
return OsLinux_HL_Login(address, label, password);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
@ -1369,6 +1388,8 @@ BOOLEAN xvt_dongle_hl_logout()
|
||||
{
|
||||
#ifdef WIN32
|
||||
return OsWin32_HL_Logout();
|
||||
#else
|
||||
return OsLinux_HL_Logout();
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
@ -1377,6 +1398,8 @@ BOOLEAN xvt_dongle_hl_read(unsigned short reg, unsigned short* data)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return OsWin32_HL_Read(reg, data);
|
||||
#else
|
||||
return OsLinux_HL_Read(reg, data);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
@ -1385,6 +1408,8 @@ BOOLEAN xvt_dongle_hl_read_block(unsigned char* data)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return OsWin32_HL_ReadBlock(data);
|
||||
#else
|
||||
return OsLinux_HL_ReadBlock(data);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
@ -1393,6 +1418,8 @@ BOOLEAN xvt_dongle_hl_write(unsigned short reg, unsigned short data)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return OsWin32_HL_Write(reg, data);
|
||||
#else
|
||||
return OsLinux_HL_Write(reg, data);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
@ -1401,6 +1428,8 @@ BOOLEAN xvt_dongle_sl_crypt(unsigned short* data)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return OsWin32_SL_Crypt(data);
|
||||
#else
|
||||
return OsLinux_SL_Crypt(data);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
@ -1409,6 +1438,8 @@ BOOLEAN xvt_dongle_sl_login(const unsigned char* label, const unsigned char* pas
|
||||
{
|
||||
#ifdef WIN32
|
||||
return OsWin32_SL_Login(label, password);
|
||||
#else
|
||||
return OsLinux_SL_Login(label, password);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
@ -1417,6 +1448,8 @@ BOOLEAN xvt_dongle_sl_logout()
|
||||
{
|
||||
#ifdef WIN32
|
||||
return OsWin32_SL_Logout();
|
||||
#else
|
||||
return OsLinux_SL_Logout();
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
@ -1425,6 +1458,8 @@ BOOLEAN xvt_dongle_sl_read_block(unsigned short reg, unsigned short size, unsign
|
||||
{
|
||||
#ifdef WIN32
|
||||
return OsWin32_SL_ReadBlock(reg, size, data);
|
||||
#else
|
||||
return OsLinux_SL_ReadBlock(reg, size, data);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
@ -1433,6 +1468,8 @@ BOOLEAN xvt_dongle_sl_write_block(unsigned short reg, unsigned short size, const
|
||||
{
|
||||
#ifdef WIN32
|
||||
return OsWin32_SL_WriteBlock(reg, size, data);
|
||||
#else
|
||||
return OsLinux_SL_WriteBlock(reg, size, data);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
@ -1486,7 +1523,7 @@ ASK_RESPONSE xvt_dm_post_ask(const char* Btn1, const char*Btn2, const char* Btn3
|
||||
int nFlags = wxCENTRE | wxICON_QUESTION | wxYES_NO;
|
||||
if (Btn3 == NULL)
|
||||
{
|
||||
if (stricmp(Btn1, "no") == 0)
|
||||
if (wxStricmp(Btn1, "no") == 0)
|
||||
nFlags |= wxNO_DEFAULT;
|
||||
}
|
||||
else
|
||||
@ -1908,7 +1945,11 @@ void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, RCT* dest, RCT* source)
|
||||
dst.x, dst.y, dst.width, dst.height,
|
||||
src.x, src.y, src.width, src.height);
|
||||
#else
|
||||
SORRY_BOX();
|
||||
const wxImage& img = ((const TXVT_IMAGE*)image)->Image();
|
||||
wxImage sub = img.GetSubImage(src);
|
||||
|
||||
sub.Rescale(dst.width, dst.height);
|
||||
dc.DrawBitmap(sub.ConvertToBitmap(), dst.GetPosition());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -2192,6 +2233,8 @@ void xvt_dwin_update(WINDOW win)
|
||||
#ifdef WIN32
|
||||
CAST_TWIN(win, w);
|
||||
OsWin32_UpdateWindow(w.GetHWND());
|
||||
#else
|
||||
OsLinux_UpdateWindow(win);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2237,7 +2280,8 @@ void xvt_font_deserialize(XVT_FNTID font_id, char *buf)
|
||||
font.SetPointSize(-nSize * 10 / 13);
|
||||
|
||||
// Ignore 4 fields
|
||||
for (int i = 0; i < 4; i++)
|
||||
int i;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
s = strchr(s+1, '/');
|
||||
if (s == NULL)
|
||||
@ -2391,7 +2435,7 @@ BOOLEAN xvt_fsys_build_pathname(char *mbs, const char *volname, const char *dirn
|
||||
#ifdef WIN32
|
||||
_makepath(mbs, volname, dirname, leafroot, leafext);
|
||||
#else
|
||||
*msb = '\0';
|
||||
*mbs = '\0';
|
||||
if (dirname && *dirname)
|
||||
strcpy(mbs, dirname);
|
||||
if (leafroot && *leafroot)
|
||||
@ -2407,7 +2451,6 @@ BOOLEAN xvt_fsys_build_pathname(char *mbs, const char *volname, const char *dirn
|
||||
strcat(mbs, leafext);
|
||||
}
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -2451,41 +2494,46 @@ BOOLEAN xvt_fsys_is_removable_drive(const char* path)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return GetDriveType(path) == DRIVE_REMOVABLE;
|
||||
#else
|
||||
char dev[_MAX_PATH];
|
||||
|
||||
OsLinux_GetFileSys(path, dev, NULL, NULL);
|
||||
return strncmp(dev, "/dev/fd", 7) == 0;
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_fsys_is_network_drive(const char* path)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return GetDriveType(path) == DRIVE_REMOTE;
|
||||
#else
|
||||
return OsLinux_IsNetworkDrive(path);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_fsys_is_fixed_drive(const char* path)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return GetDriveType(path) == DRIVE_FIXED;
|
||||
#else
|
||||
return !(xvt_fsys_is_network_drive(path) || xvt_fsys_is_removable_drive(path));
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static unsigned long compute_disk_size(const char* path, bool tot, char unit)
|
||||
{
|
||||
#ifdef WIN32
|
||||
char drive[_MAX_DRIVE+1];
|
||||
_splitpath(path, drive, NULL, NULL, NULL);
|
||||
xvt_sys_splitpath(path, drive, NULL, NULL, NULL);
|
||||
strcat(drive, "/");
|
||||
DWORD nSecPerClust, nBytePerSec, nFreeClust, nTotalClust;
|
||||
::GetDiskFreeSpace(drive, &nSecPerClust, &nBytePerSec, &nFreeClust, &nTotalClust);
|
||||
__int64 nBytes = tot ? nTotalClust : nFreeClust;
|
||||
nBytes *= nSecPerClust;
|
||||
nBytes *= nBytePerSec;
|
||||
|
||||
#else
|
||||
unsigned long nBytes = 1024*1024;
|
||||
if (!xvt_fsys_is_removable_drive(path))
|
||||
nBytes *= 1024;
|
||||
int64_t nBytes = OsLinux_GetDiskFreeSpace(path);
|
||||
#endif
|
||||
|
||||
switch (unit)
|
||||
@ -2494,7 +2542,8 @@ static unsigned long compute_disk_size(const char* path, bool tot, char unit)
|
||||
case 'M': nBytes >>= 20; break; // Megabytes
|
||||
case 'G': nBytes >>= 30; break; // Gigabytes
|
||||
case 'T': nBytes >>= 40; break; // Terabytes
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const unsigned long nMax = (unsigned long)(~0L);
|
||||
@ -2735,7 +2784,7 @@ void xvt_image_transfer(XVT_IMAGE dstimage, XVT_IMAGE srcimage, RCT *dstrctp, RC
|
||||
const wxRect rctDst = NormalizeRCT(dstrctp);
|
||||
const wxRect rctSrc = NormalizeRCT(srcrctp);
|
||||
|
||||
wxImage sub = src.GetSubImage(NormalizeRCT(srcrctp));
|
||||
wxImage sub = src.GetSubImage(rctSrc);
|
||||
sub.Rescale(rctDst.width, rctDst.height);
|
||||
if (rctDst.x == 0 && rctDst.y == 0)
|
||||
dst = sub;
|
||||
@ -2786,7 +2835,9 @@ DATA_PTR xvt_mem_zalloc(size_t size)
|
||||
|
||||
int xvt_menu_count(const MENU_ITEM* m)
|
||||
{
|
||||
for (int n = 0; m[n].tag != 0; n++);
|
||||
int n;
|
||||
|
||||
for (n = 0; m[n].tag != 0; n++);
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -2825,7 +2876,7 @@ MENU_ITEM* xvt_menu_get_tree(WINDOW win)
|
||||
return m;
|
||||
}
|
||||
|
||||
static TranslateMenu(wxMenu* pMenu, TRANSLATE_CALLBACK tc)
|
||||
static void TranslateMenu(wxMenu* pMenu, TRANSLATE_CALLBACK tc)
|
||||
{
|
||||
wxMenuItemList& list = pMenu->GetMenuItems();
|
||||
for (unsigned i = 0; i < list.GetCount(); i++)
|
||||
@ -3094,7 +3145,7 @@ MENU_ITEM* xvt_res_get_menu(int rid)
|
||||
{
|
||||
wxFileName::SplitPath(wxTheApp->argv[0], NULL, &strName, NULL);
|
||||
strName.MakeUpper();
|
||||
strName = wxString::Format("/Menu_%s-%X", strName.Left(3), (rid-1)%16);
|
||||
strName = wxString::Format("/Menu_%s-%X", (const char *) strName.Left(3), (rid-1)%16);
|
||||
}
|
||||
else
|
||||
strName = wxString::Format("/Menu_%d", rid);
|
||||
@ -3486,6 +3537,8 @@ long xvt_sys_execute_in_window(const char* cmdline, WINDOW win)
|
||||
#ifdef WIN32
|
||||
if (inst > 0)
|
||||
OsWin32_PlaceProcessInWindow(inst, "", xvt_vobj_get_attr(ATTR_NATIVE_WINDOW, win));
|
||||
#else
|
||||
OsLinux_PlaceProcessInWindow(inst, "", xvt_vobj_get_attr(ATTR_NATIVE_WINDOW, win));
|
||||
#endif
|
||||
return inst;
|
||||
}
|
||||
@ -3563,12 +3616,12 @@ BOOLEAN xvt_sys_find_editor(const char* file, char* editor)
|
||||
|
||||
#ifdef WIN32
|
||||
const wxString e = OsWin32_File2App(file);
|
||||
#else
|
||||
const wxString e = OsLinux_File2App(file);
|
||||
#endif
|
||||
ok = !e.IsEmpty();
|
||||
if (ok && editor != NULL)
|
||||
strcpy(editor, e);
|
||||
#else
|
||||
SORRY_BOX();
|
||||
#endif
|
||||
|
||||
return ok;
|
||||
}
|
||||
@ -3592,7 +3645,8 @@ unsigned int xvt_sys_load_icon(const char* file)
|
||||
icon->SetHICON(hicon);
|
||||
}
|
||||
#else
|
||||
id = ICON_RSRC; // TBI
|
||||
icon = new wxIcon;
|
||||
// icon = new wxIcon(wxICON(file)); //verificare
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -3608,7 +3662,11 @@ unsigned int xvt_sys_load_icon(const char* file)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef WIN32
|
||||
if (ico->GetHICON() == icon->GetHICON()) // C'e' gia'
|
||||
#else
|
||||
if (ico == icon) // C'e' gia'
|
||||
#endif
|
||||
{
|
||||
delete icon;
|
||||
break;
|
||||
@ -3664,6 +3722,73 @@ BOOLEAN xvt_sys_test_network_version()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// XVT system calls (added by Alex)
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
void xvt_sys_searchenv(const char * filename, const char * varname, char * pathname)
|
||||
{
|
||||
#ifdef WIN32
|
||||
_searchenv(filename, varname, pathname);
|
||||
#else
|
||||
const char * value = getenv(varname);
|
||||
if (value)
|
||||
{
|
||||
char path_list[4096];
|
||||
const char * s = path_list;
|
||||
|
||||
strcpy(path_list, value);
|
||||
do
|
||||
{
|
||||
char * s1 = strchr(s, ';');
|
||||
|
||||
if (s1 != NULL)
|
||||
*s1 = '\0';
|
||||
|
||||
char fname[256];
|
||||
|
||||
strcpy(fname, s);
|
||||
strcat(fname, filename);
|
||||
if (wxFileExists(fname))
|
||||
strcpy(pathname, s);
|
||||
if (s1 != NULL)
|
||||
s = s1 + 1;
|
||||
} while (s);
|
||||
|
||||
}
|
||||
else
|
||||
*pathname = '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOLEAN xvt_fsys_access(const char *pathname, int mode)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return _access(pathname, mode);
|
||||
#else
|
||||
return access(pathname, mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOLEAN xvt_fsys_file_exists(const char *pathname)
|
||||
{
|
||||
return wxFileExists(pathname);
|
||||
}
|
||||
|
||||
BOOLEAN xvt_fsys_mkdir(const char *pathname)
|
||||
{
|
||||
return wxMkdir(pathname);
|
||||
}
|
||||
|
||||
BOOLEAN xvt_fsys_rmdir(const char *pathname)
|
||||
{
|
||||
return wxRmdir(pathname);
|
||||
}
|
||||
|
||||
BOOLEAN xvt_fsys_removefile(const char *pathname)
|
||||
{
|
||||
return wxRemoveFile(pathname);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Timers
|
||||
@ -3769,15 +3894,23 @@ long xvt_vobj_get_attr(WINDOW win, long data)
|
||||
case ATTR_NATIVE_GRAPHIC_CONTEXT:
|
||||
if (_nice_windows.Get(win) != NULL)
|
||||
{
|
||||
#ifdef WIN32
|
||||
CAST_DC(win, dc);
|
||||
ret = dc.GetHDC();
|
||||
#else
|
||||
SORRY_BOX(); //verificare
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case ATTR_NATIVE_WINDOW:
|
||||
if (_nice_windows.Get(win) != NULL)
|
||||
{
|
||||
#ifdef WIN32
|
||||
CAST_WIN(win, w);
|
||||
ret = w.GetHandle();
|
||||
#else
|
||||
SORRY_BOX(); //verificare
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case ATTR_SCREEN_HEIGHT:
|
||||
@ -4179,7 +4312,7 @@ XVT_FNTID statbar_set_fontid(WINDOW win, XVT_FNTID fontid)
|
||||
|
||||
XVT_FNTID statbar_get_fontid(WINDOW win, XVT_FNTID fontid)
|
||||
{
|
||||
return fontid; // TBI???
|
||||
return fontid; // VERIFICARE
|
||||
}
|
||||
|
||||
WINDOW statbar_create(int cid, int left, int top, int right, int bottom,
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "..\xvaga\wxinc.h"
|
||||
#include "../xvaga/wxinc.h"
|
||||
|
||||
extern int xvt_main(int argc, char** argv);
|
||||
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
bool operator==(const TFontId& f) const { return IsEqual(f); }
|
||||
bool operator!=(const TFontId& f) const { return !IsEqual(f); }
|
||||
|
||||
TFontId() : m_win(NULL_WIN), m_nSize(0), m_wMask(0) { }
|
||||
TFontId() : m_nSize(0), m_wMask(0), m_win(NULL_WIN) { }
|
||||
TFontId(const TFontId& f) : m_win(NULL_WIN) { Copy(f); }
|
||||
};
|
||||
|
||||
|
16
xvaga/xvt.h
16
xvaga/xvt.h
@ -2,14 +2,12 @@
|
||||
#define XVT_INCL_XVT
|
||||
|
||||
#ifdef XVT_INCL_NATIVE
|
||||
|
||||
#ifdef WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
@ -18,6 +16,7 @@
|
||||
#else
|
||||
#define XVTDLL __declspec(dllimport)
|
||||
#endif
|
||||
#include <io.h>
|
||||
#else
|
||||
#define XVTDLL
|
||||
#endif
|
||||
@ -25,7 +24,6 @@
|
||||
#define XVAGA 1
|
||||
|
||||
#include <ctype.h>
|
||||
#include <io.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -162,6 +160,11 @@ XVTDLL BOOLEAN xvt_fsys_is_removable_drive(const char* path);
|
||||
XVTDLL BOOLEAN xvt_fsys_is_network_drive(const char* path);
|
||||
XVTDLL BOOLEAN xvt_fsys_is_fixed_drive(const char* path);
|
||||
XVTDLL BOOLEAN xvt_fsys_test_disk_free_space(const char* path, unsigned long filesize);
|
||||
XVTDLL BOOLEAN xvt_fsys_mkdir(const char *pathname);
|
||||
XVTDLL BOOLEAN xvt_fsys_rmdir(const char *pathname);
|
||||
XVTDLL BOOLEAN xvt_fsys_removefile(const char *pathname);
|
||||
XVTDLL BOOLEAN xvt_fsys_access(const char *pathname, int mode);
|
||||
XVTDLL BOOLEAN xvt_fsys_file_exists(const char *pathname);
|
||||
|
||||
XVTDLL void xvt_help_close_helpfile(XVT_HELP_INFO hi);
|
||||
XVTDLL XVT_HELP_INFO xvt_help_open_helpfile(FILE_SPEC *fs, unsigned long flags);
|
||||
@ -285,10 +288,10 @@ XVTDLL int xvt_sys_get_os_version();
|
||||
XVTDLL unsigned int xvt_sys_load_icon(const char* file);
|
||||
XVTDLL void xvt_sys_sleep(unsigned long msec);
|
||||
XVTDLL BOOLEAN xvt_sys_test_network_version();
|
||||
|
||||
XVTDLL void xvt_sys_searchenv(const char *filename, const char *varname, char *pathname);
|
||||
XVTDLL void xvt_sys_sorry_box(const char * file, int line);
|
||||
XVTDLL long xvt_timer_create(WINDOW win, long interval);
|
||||
XVTDLL void xvt_timer_destroy(long id);
|
||||
|
||||
XVTDLL void xvt_vobj_destroy(WINDOW win);
|
||||
XVTDLL long xvt_vobj_get_attr(WINDOW win, long data);
|
||||
XVTDLL RCT* xvt_vobj_get_client_rect(WINDOW win, RCT *rctp);
|
||||
@ -309,7 +312,6 @@ XVTDLL void xvt_vobj_set_palet(WINDOW win, XVT_PALETTE palet);
|
||||
XVTDLL void xvt_vobj_set_title(WINDOW win, char *title);
|
||||
XVTDLL void xvt_vobj_set_visible(WINDOW win, BOOLEAN show);
|
||||
XVTDLL void xvt_vobj_translate_points(WINDOW from_win, WINDOW to_win, PNT *pntp, int npnts);
|
||||
|
||||
XVTDLL WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WINDOW parent_win, long win_flags, EVENT_MASK mask, EVENT_HANDLER eh, long app_data);
|
||||
XVTDLL long xvt_win_dispatch_event(WINDOW win, EVENT* event_p);
|
||||
XVTDLL void xvt_win_post_event(WINDOW win, EVENT* event_p); // Added by XVAGA
|
||||
@ -325,4 +327,6 @@ XVTDLL void xvt_win_trap_pointer(WINDOW win);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define SORRY_BOX() xvt_sys_sorry_box(__FILE__, __LINE__)
|
||||
|
||||
#endif
|
||||
|
@ -1,9 +1,19 @@
|
||||
#ifndef BOOLEAN
|
||||
#define BOOLEAN short
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifdef LINUX
|
||||
#define _MAX_PATH 512
|
||||
#define _MAX_EXT 6
|
||||
#define _MAX_DRIVE 6
|
||||
#define _MAX_DIR 512
|
||||
#define _MAX_FNAME 512
|
||||
#endif
|
||||
|
||||
typedef unsigned long WINDOW;
|
||||
typedef unsigned int UNIT_TYPE;
|
||||
typedef unsigned long ULONG;
|
||||
|
@ -3,7 +3,12 @@
|
||||
#include "wx/printdlg.h"
|
||||
|
||||
#include "xvt.h"
|
||||
#ifdef WIN32
|
||||
#include "oswin32.h"
|
||||
#else
|
||||
#include "oslinux.h"
|
||||
#include <fstream.h>
|
||||
#endif
|
||||
|
||||
#include "xvintern.h"
|
||||
|
||||
@ -80,18 +85,22 @@ void TwxPrintOut::InitDC(TPRINT_RCD* prcd)
|
||||
if (m_prcd == NULL)
|
||||
{
|
||||
wxPrinter printer;
|
||||
#ifdef WIN32
|
||||
dc = new wxPrinterDC(printer.GetPrintDialogData().GetPrintData());
|
||||
#else
|
||||
dc = new wxPostScriptDC(printer.GetPrintDialogData().GetPrintData());
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
wxPrintData data;
|
||||
#ifdef WIN32
|
||||
data.SetNativeData(OsWin32_ConvertToNativePrinterInfo(prcd->m_data, prcd->m_size));
|
||||
#else
|
||||
data.SetNativeData(prcd->m_data);
|
||||
#endif
|
||||
data.ConvertFromNative();
|
||||
dc = new wxPrinterDC(data);
|
||||
#else
|
||||
dc = new wxPostScriptDC(prcd->m_data);
|
||||
#endif
|
||||
}
|
||||
|
||||
wxSize s = dc->GetPPI();
|
||||
@ -180,22 +189,20 @@ BOOLEAN xvt_dm_post_page_setup(PRINT_RCD* precp)
|
||||
|
||||
#ifdef WIN32
|
||||
data.SetNativeData(OsWin32_ConvertToNativePrinterInfo(rcd->m_data, rcd->m_size));
|
||||
#else
|
||||
data.SetNativeData(rcd->m_data);
|
||||
#endif
|
||||
data.ConvertFromNative();
|
||||
#endif
|
||||
|
||||
if (dlg.ShowModal() == wxID_OK)
|
||||
{
|
||||
#ifdef WIN32
|
||||
data.ConvertToNative();
|
||||
void* pHandle = data.GetNativeData();
|
||||
#ifdef WIN32
|
||||
unsigned int nSize = 0;
|
||||
void* ptr = OsWin32_ConvertFromNativePrinterInfo(pHandle, nSize);
|
||||
rcd->SetData(ptr, nSize);
|
||||
delete ptr;
|
||||
#else
|
||||
rcd->SetData(pHandle, 1024);
|
||||
rcd->SetData((void *) &data, (unsigned int) sizeof(data));
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
@ -209,13 +216,16 @@ long xvt_fmap_get_family_sizes(PRINT_RCD *precp, char *family, long *size_array,
|
||||
size_array[0] = 13;
|
||||
*scalable = FALSE;
|
||||
|
||||
#ifdef WIN32
|
||||
if (precp != NULL)
|
||||
{
|
||||
#ifdef WIN32
|
||||
TwxPrintOut* po = new TwxPrintOut((TPRINT_RCD*)precp);
|
||||
|
||||
size = OsWin32_EnumerateSizes(po->GetDC()->GetHDC(), family, size_array, scalable, max_sizes);
|
||||
}
|
||||
#else
|
||||
size = OsLinux_EnumerateSizes(family, size_array, scalable, max_sizes);
|
||||
#endif
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
@ -225,13 +235,16 @@ long xvt_fmap_get_families(PRINT_RCD *precp, char **family_array, long max_famil
|
||||
long size = 1;
|
||||
family_array[0] = xvt_str_duplicate(XVT_FFN_COURIER);
|
||||
|
||||
#ifdef WIN32
|
||||
if (precp != NULL)
|
||||
{
|
||||
#ifdef WIN32
|
||||
TwxPrintOut* po = new TwxPrintOut((TPRINT_RCD*)precp);
|
||||
|
||||
size = OsWin32_EnumerateFamilies(po->GetDC()->GetHDC(), family_array, max_families);
|
||||
}
|
||||
#else
|
||||
size = OsLinux_EnumerateFamilies(family_array, max_families);
|
||||
#endif
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@ -263,6 +276,13 @@ PRINT_RCD* xvt_print_create(int *sizep)
|
||||
*sizep += 4; // Spazio per puntatore iniziale
|
||||
delete data;
|
||||
}
|
||||
#else
|
||||
wxPrinter printer;
|
||||
wxPrintData &data = printer.GetPrintDialogData().GetPrintData();
|
||||
|
||||
data.SetPrinterName(""); //verificare
|
||||
pr = new TPRINT_RCD;
|
||||
pr->SetData((void *) &data, (unsigned int) sizeof(data));
|
||||
#endif
|
||||
|
||||
return pr;
|
||||
@ -283,6 +303,14 @@ PRINT_RCD* xvt_print_create_by_name(int* sizep, const char* name)
|
||||
*sizep += 4; // Spazio per puntatore iniziale
|
||||
delete data;
|
||||
}
|
||||
#else
|
||||
wxPrinter printer;
|
||||
wxPrintData &data = printer.GetPrintDialogData().GetPrintData();
|
||||
wxString PrinterName(name);
|
||||
|
||||
data.SetPrinterName(PrinterName); //verificare
|
||||
pr = new TPRINT_RCD;
|
||||
pr->SetData((void *) &data, (unsigned int) sizeof(data));
|
||||
#endif
|
||||
|
||||
return pr;
|
||||
@ -333,6 +361,8 @@ BOOLEAN xvt_print_is_valid(PRINT_RCD* precp)
|
||||
#ifdef WIN32
|
||||
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
|
||||
ok = OsWin32_CheckPrinterInfo(rcd->m_data, rcd->m_size);
|
||||
#else
|
||||
// verificare (c'e' da fare qualcosa ?)
|
||||
#endif
|
||||
}
|
||||
return ok;
|
||||
@ -345,7 +375,6 @@ BOOLEAN xvt_print_open(void)
|
||||
|
||||
BOOLEAN xvt_print_start_thread(BOOLEAN(*print_fcn)(long), long data)
|
||||
{
|
||||
wxWindow* tw = (wxWindow*)TASK_WIN;
|
||||
m_po = new TwxPrintOut;
|
||||
|
||||
print_fcn(data);
|
||||
@ -371,6 +400,17 @@ BOOLEAN xvt_print_open_page(PRINT_RCD* precp)
|
||||
// Added by XVAGA
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef LINUX
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
|
||||
SLIST xvt_print_list_devices()
|
||||
{
|
||||
SLIST list = xvt_slist_create();
|
||||
@ -387,7 +427,63 @@ SLIST xvt_print_list_devices()
|
||||
start = i+1;
|
||||
}
|
||||
#else
|
||||
xvt_slist_add_at_elt(list, NULL, "/dev/prn", NULL); // TBI
|
||||
if (is_cups())
|
||||
{
|
||||
ifstream p("/etc/cups/printer.conf"); // vedere
|
||||
char line[4096];
|
||||
|
||||
while (p.getline(line, sizeof(line)))
|
||||
{
|
||||
if (line[0] == '<')
|
||||
{
|
||||
char * s = strstr(line, "Printer") ;
|
||||
|
||||
if (s != NULL)
|
||||
{
|
||||
s += 7;
|
||||
|
||||
while (isspace(*s))
|
||||
s++;
|
||||
|
||||
if (*s)
|
||||
{
|
||||
char * l = s + strlen(s) - 1;
|
||||
|
||||
while (isspace(*l))
|
||||
l--;
|
||||
*(l + 1) = '\0';
|
||||
xvt_slist_add_at_elt(list, NULL, s, 0L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ifstream p("/etc/printcap"); // vedere
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
return list;
|
||||
}
|
||||
@ -407,18 +503,53 @@ BOOLEAN xvt_print_set_default_device(const char* name)
|
||||
}
|
||||
ok = ::WriteProfileString("windows", "device", pdev) != 0;
|
||||
}
|
||||
#else
|
||||
SORRY_BOX(); //verificare
|
||||
#endif
|
||||
return ok;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_print_get_default_device(char* name, int namesize)
|
||||
{
|
||||
bool ok = TRUE;
|
||||
bool ok = FALSE;
|
||||
#ifdef WIN32
|
||||
ok = ::GetProfileString ("windows", "device", ",,,", name, namesize) != 0;
|
||||
#else
|
||||
strcpy(name, "/dev/prn");
|
||||
*name = '\0';
|
||||
if (is_cups())
|
||||
{
|
||||
ifstream p("/etc/cups/printer.conf"); // vedere
|
||||
char line[4096];
|
||||
|
||||
while (p.getline(line, sizeof(line)))
|
||||
{
|
||||
if (line[0] == '<')
|
||||
{
|
||||
char * s = strstr(line, "ltPrinter") ;
|
||||
|
||||
if (s != NULL)
|
||||
{
|
||||
s += 9;
|
||||
|
||||
while (isspace(*s))
|
||||
s++;
|
||||
|
||||
if (*s)
|
||||
{
|
||||
char * l = s + strlen(s) - 1;
|
||||
|
||||
while (isspace(*l))
|
||||
l--;
|
||||
*(l + 1) = '\0';
|
||||
strcpy(name, s);
|
||||
}
|
||||
ok = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user